Sample
pyint-7d50e63d98a1-I13
Lower every eligible synchronous for loop to a while loop
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0.023 | 0–1; higher is more readable |
| Dorn | 0.462 | 0–1; higher is more readable |
| Mi | 0.512 | 0–1; higher is more readable |
| LLOC | 6 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 18 | 0–20; mean of three runs |
| GPT-6.1 Sol | 16 | 0–20; mean of three runs |
| BTTF | 0.678 | 0–1; higher is more readable |
Views
Loading feature diagnosis…
Source regions
Feature contributions
Feature contributions
| Feature | Value | Contribution (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. | 330.619 | −10.91 |
| 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.88 | −7.319 |
| Source linesThe number of non-empty source lines. | 14 | +5.6 |
Intercept 8.87 + feature contributions = -3.76 (log-odds).
Score = sigmoid(-3.76) = 0.023.
Feature contributions
| Feature | Value | Contribution (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.805 | −0.217 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.106 | −0.086 |
Intercept 0.07 + feature contributions = -0.152 (log-odds).
Score = sigmoid(-0.152) = 0.462.
| Score | 0.512 |
|---|
| Score | 6 |
|---|
Run 1
The code is highly readable. It has a clear, logical structure with imports organized by standard library modules and typing utilities. Nesting is essentially flat — the only indented block is a minimal Protocol method definition. Intent is explicit: it defines a runtime-checkable structural protocol for objects with a `read` method. The code is concise, avoiding any unnecessary verbosity. Action granularity is appropriate, with each import grouping and the Protocol definition on separate logical lines. Reading flow is natural, from future imports down to the protocol definition. The only minor deduction is that the lengthy import block could be slightly streamlined, but it is well-organized and conventional.
Run 2
This code is highly readable. It demonstrates clean structure with logical organization: future import, grouped typing imports, and a single Protocol class. Nesting is non-existent—the code is entirely flat. Intent is clear: it defines a runtime-checkable protocol for objects with a `read` method. Length is concise and appropriate for its purpose. Action granularity is excellent, with one action per line. Reading flow is natural, following standard Python import conventions. Minor deductions only for minor verbosity in typing imports, but overall it exemplifies best practices.
Run 3
The code is clean and well-structured. It groups imports logically (future, abc, typing) and uses explicit type hints. The Protocol definition is concise, with clear intent and flat nesting. Minor deductions: the typing import block spans multiple lines but could be more compact, and the `length: int = ...` default uses an ellipsis which may require familiarity with typing conventions. Overall, the code is highly readable with a natural flow and one clear action per section.
Run 1
Code Structure: Imports followed by a protocol declaration provide a logical organization, though many imports are unused in this snippet. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: SupportsRead and read clearly describe the interface, but the undeclared _T_co and specialized typing syntax require additional context. Code length: The protocol is concise, while the import list is longer than the shown functionality needs. Action granularity: Each statement has a distinct purpose; the one-line method declaration is appropriate for a protocol stub. Reading flow: The progression from imports to interface is natural, although additional spacing between imports and the decorated class would improve visual separation.
Run 2
Code Structure: Imports and the protocol definition are logically organized, although _T_co is not defined in the snippet and several imports are unused. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: SupportsRead and read clearly express a readable-object interface, but the undeclared type variable and specialized typing syntax reduce standalone clarity. Code length: The protocol is concise, while the broad import list adds unnecessary length for the code shown. Action granularity: Each import, decorator, class declaration, and method declaration has a distinct role; the inline ellipsis is conventional for a protocol stub. Reading flow: The progression from imports to interface is natural, though an explicit type-variable declaration and additional spacing before the class would improve readability.
Run 3
Code Structure: Imports and the protocol definition are logically organized, though several imports are unused and _T_co is not defined in the snippet. Nesting: Minimal, with only a method inside a class. Clarity of intent: SupportsRead, read, and the return annotation clearly describe a readable-object interface; the undefined type variable and specialized typing syntax reduce immediate clarity. Code length: The definition is concise, but unused imports add clutter. Action granularity: Each statement serves a distinct purpose; the one-line method stub is appropriate for a protocol. Reading flow: Natural progression from imports to decorator, class, and method, although an additional blank line before the top-level class would improve formatting.