Sample

pyint-aa99fae2423b-I13

Lower every eligible synchronous for loop to a while loop

Matched original source

Lines12

Scores

MethodScoreScale
Posnett0.2770–1; higher is more readable
Dorn0.8530–1; higher is more readable
Mi0.7510–1; higher is more readable
LLOC9Logical lines; fewer is more readable
DeepSeek V4 Pro14.330–20; mean of three runs
GPT-6.1 Sol17.330–20; mean of three runs
BTTF0.7820–1; higher is more readable

Views

Source code

from __future__ import annotations import re from typing import Any, Dict, List, Tuple import attr import attrs @attr.s(auto_detect=True) class AutoDetect: x: int def __init__(self, x: int): self.x = x

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.242.899−8.016
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.411−6.616
Source linesThe number of non-empty source lines.12+4.8

Intercept 8.87 + feature contributions = -0.961 (log-odds).
Score = sigmoid(-0.961) = 0.277.

Feature contributions

FeatureValueContribution
(log-odds)
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.40.846+1.935
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.13+0.576
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.12−0.322
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.11.786−0.245
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.082+0.148

Intercept 0.07 + feature contributions = 1.755 (log-odds).
Score = sigmoid(1.755) = 0.853.

Score0.751
Score9
Run 1

The code is highly readable due to its simplicity and clean structure. It demonstrates a clear, focused purpose: defining a single attrs class with an explicit initializer. The structure is logical, with imports grouped, followed by the class definition. Nesting is minimal, with only a single method inside the class. Intent is unambiguous; the class name and attribute type hint make the purpose clear. Code length is concise, with no unnecessary logic. Each action (import statements, decorator, attribute, method, assignment) is on its own line, improving granularity. The reading flow is natural, from imports to class to method. Minor deductions are for the redundant `@attr.s(auto_detect=True)` decorator when a manual `__init__` is provided, which could confuse intent slightly, and the import of `re`, `Any`, `Dict`, `List`, `Tuple`, and `attrs` are unused. These unused imports slightly reduce clarity but do not significantly impact readability.

Run 2

The code is short and syntactically clear, but it has several structural and conceptual issues that lower readability. The import of both `attr` and `attrs` suggests confusion or redundant dependencies. The class uses `@attr.s(auto_detect=True)` while also defining a manual `__init__`, which defeats the purpose of using attrs and may cause unexpected behavior. The class name `AutoDetect` and attribute `x` lack descriptive context. There is no clear intent for the class's purpose. Nesting is flat, and action granularity is fine, but the logical organization and clarity of intent suffer. The reading flow is simple but disjointed due to the redundant constructor and unclear naming. Overall, it is readable in syntax but not in purpose or design.

Run 3

The code is generally readable but has some issues. It defines a class using two different libraries (attr and attrs) but only uses one, which is confusing. The explicit __init__ method is redundant with attr.s(auto_detect=True), adding unnecessary length. The imports include unused ones (re, Any, Dict, List, Tuple, attrs), reducing clarity of intent. Structure is simple and flat, and action granularity is fine, but the reading flow is interrupted by the pointless imports and redundant code.

Run 1

Code Structure: Imports and the class are logically organized, although several imports are unused. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The typed attribute and explicit constructor clearly initialize x, but the generic class name and auto_detect decorator leave the broader purpose unclear. Code length: Very concise, though unused imports add clutter. Action granularity: Each statement performs one action. Reading flow: Natural top-to-bottom flow; grouping imports and adding another blank line before the class would improve formatting.

Run 2

Code Structure: Imports and the class are logically organized, though several imports are unused. Nesting: Minimal nesting makes the code easy to follow. Clarity of intent: The annotated field and constructor clearly define initialization, but the generic class name and auto_detect decorator leave the broader purpose unclear. Code length: Short and focused, with minor clutter from unused imports. Action granularity: Each line performs a single action. Reading flow: Natural top-to-bottom progression, though a blank line after the future import and two blank lines before the class would improve conventional formatting.

Run 3

Code Structure: Imports and the class are logically organized, though several imports are unused and importing both attr and attrs adds clutter. Nesting: Minimal nesting makes the code easy to follow. Clarity of intent: The typed field and constructor clearly show that the class stores an integer, but the generic class name and auto_detect decorator leave its broader purpose unclear. Code length: Very short, although unused imports are unnecessary. Action granularity: Each line performs a single action. Reading flow: Natural top-to-bottom flow, with minor formatting improvements possible, such as separating import groups and adding another blank line before the class.