Sample

pyint-4158757dc6a4-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines14

Scores

MethodScoreScale
Posnett0.0190–1; higher is more readable
Dorn0.4870–1; higher is more readable
Mi0.4830–1; higher is more readable
LLOC6Logical lines; fewer is more readable
DeepSeek V4 Pro17.670–20; mean of three runs
GPT-6.1 Sol16.330–20; mean of three runs
BTTF0.6930–1; higher is more readable

Views

Source code

from __future__ import annotations from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequence from typing import ( TYPE_CHECKING, Any, Protocol, TypeAlias, TypeVar, runtime_checkable, ) @runtime_checkable class SupportsItems(Protocol[_KT_co, _VT_co]): def items(self) -> Iterable[tuple[_KT_co, _VT_co]]: ...

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.336.045−11.089
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.883−7.325
Source linesThe number of non-empty source lines.14+5.6

Intercept 8.87 + feature contributions = -3.944 (log-odds).
Score = sigmoid(-3.944) = 0.019.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.15+0.505
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Indentation frequencyHow rapidly indentation changes from line to line.14−0.253
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.81+0.234
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.13.78−0.217
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.095+0.015

Intercept 0.07 + feature contributions = -0.052 (log-odds).
Score = sigmoid(-0.052) = 0.487.

Score0.483
Score6
Run 1

The code is concise, well-structured, and purpose-driven. It uses a clear Protocol definition with runtime checkability, proper generic type variables, and a self-explanatory method signature. Imports are organized and minimal, with future annotations for compatibility. Nesting is absent, and action granularity is one concept per line. The only minor drawbacks are reliance on implicit conventions (underscore naming for type vars) and slight verbosity in import grouping, which could affect beginners.

Run 2

This code defines a single runtime-checkable protocol with clear intent, logical structure, and flat nesting. It uses modern typing patterns (PEP 695-style TypeVar defaults) and benefits from explicit imports. However, readability is slightly reduced by the use of underscore-prefixed type variables and `_KT_co`/`_VT_co` naming, which assumes familiarity with naming conventions. The import block is somewhat verbose but organized. Overall, clarity and conciseness are strong.

Run 3

This code is exceptionally readable. It has a clear, logical structure: future import, organized stdlib imports, typing imports, and a single well-defined Protocol class. Nesting is nonexistent. The intent — defining a runtime-checkable Protocol for objects with an `.items()` method — is explicit and unambiguous. The code is concise, with no unnecessary lines. Each line performs one clear action (import group, decorator, class definition, method signature). The reading flow is natural, moving from general imports to the specific protocol definition.

Run 1

Code Structure: Imports and the protocol definition are logically organized, though the referenced type variables are not defined in the snippet. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: SupportsItems and its typed items method clearly describe an interface for objects exposing key-value pairs; undefined type variables and unused imports introduce some ambiguity. Code length: The implementation is concise, but several imports appear unnecessary in this excerpt. Action granularity: Each statement has a distinct purpose; the inline ellipsis is a conventional, readable protocol stub. Reading flow: The progression from imports to decorator to interface is natural, although an additional blank line before the top-level class would improve visual separation.

Run 2

Code Structure: Imports and the protocol definition are logically organized, though several imports are unused in this snippet. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: SupportsItems clearly describes an interface for objects exposing items(), and the return annotation is informative; however, _KT_co and _VT_co are not defined in the provided code, leaving their roles incomplete. Code length: The implementation is concise, but the unused imports add clutter. Action granularity: Each statement has a distinct purpose, and the inline ellipsis is appropriate for a protocol method stub. Reading flow: The progression from imports to decorator to interface is natural, although missing type-variable declarations interrupt comprehension.

Run 3

Code Structure: Imports and the protocol declaration are logically organized, though the type variables are not defined in the shown snippet. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: SupportsItems and its typed items method clearly describe an interface, but undefined type variables and several unused imports introduce uncertainty. Code length: The implementation is concise, although the import list is unnecessarily broad for this snippet. Action granularity: Each statement has a distinct purpose; the inline ellipsis is conventional for protocol methods. Reading flow: The progression from imports to decorator to class is natural, but an additional blank line before the top-level class would improve visual separation.