Sample

pyint-cc36a36ab088-I13

Lower every eligible synchronous for loop to a while loop

Matched original source

Lines17

Scores

MethodScoreScale
Posnett0.9880–1; higher is more readable
Dorn0.8370–1; higher is more readable
Mi0.8190–1; higher is more readable
LLOC7Logical lines; fewer is more readable
DeepSeek V4 Pro17.330–20; mean of three runs
GPT-6.1 Sol190–20; mean of three runs
BTTF0.7620–1; higher is more readable

Views

Source code

from __future__ import annotations class FrozenError(AttributeError): """ A frozen/immutable instance or attribute have been attempted to be modified. It mirrors the behavior of ``namedtuples`` by using the same error message and subclassing `AttributeError`. .. versionadded:: 20.1.0 """ def __init__(self): msg = "can't set attribute" super().__init__(msg) self.msg = msg

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Source linesThe number of non-empty source lines.17+6.8
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.447−6.671
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.140.182−4.626

Intercept 8.87 + feature contributions = 4.373 (log-odds).
Score = sigmoid(4.373) = 0.988.

Feature contributions

FeatureValueContribution
(log-odds)
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.033+0.622
Indentation frequencyHow rapidly indentation changes from line to line.9−0.426
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.18+0.399
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.73.556+0.382
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.78+0.361
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.16.873−0.174

Intercept 0.07 + feature contributions = 1.633 (log-odds).
Score = sigmoid(1.633) = 0.837.

Score0.819
Score7
Run 1

The code is highly readable. Structure is logical and well-organized: a custom exception class with a clear docstring, proper inheritance from AttributeError, and a straightforward __init__ method. Nesting is minimal and flat. Intent is unambiguous—creating a frozen attribute error mirroring namedtuple behavior. Length is concise with no unnecessary code. Each action (creating message, calling super, assigning attribute) is on its own line, following clean action granularity. Reading flow is natural, from class definition to docstring to initialization. Minor deductions: the 'msg' attribute assignment is slightly redundant since the message is already stored by the base exception, and the docstring could be trimmed, but these are trivial and don't hinder comprehension.

Run 2

The code is highly readable with a clear, single-purpose class definition. Structure is logical: import, class, docstring, and method. No nesting exists. Intent is explicit through the class name, docstring, and message. Length is concise yet complete. Each action (super init, attr assignment) is on its own line. Reading flow is natural from top to bottom. Minor deduction only because the `msg` attribute on a custom exception is non-standard, but this is acceptable.

Run 3

The code is well-structured and easy to read. It defines a custom exception with a clear, single responsibility. The class has a flat structure with no nesting, and the constructor performs one logical action. Variable names are descriptive, and the docstring provides useful context about the class's purpose and behavior. The only minor improvement could be using a direct string argument to super().__init__ instead of assigning self.msg separately, but this is negligible and doesn't affect readability. Overall, the code is concise, unambiguous, and follows Python conventions.

Run 1

Code Structure: The import, exception class, documentation, and initializer are logically organized. Nesting: Only standard class and method nesting is present. Clarity of intent: The class name, AttributeError inheritance, and docstring clearly identify an exception for attempted mutation of frozen objects, though the docstring's opening sentence is grammatically awkward. Code length: The implementation is concise; storing the message in self.msg appears slightly redundant but may serve callers. Action granularity: Each executable line performs one clear action. Reading flow: The code reads naturally from purpose to message construction, superclass initialization, and message storage.

Run 2

Code Structure: Clearly organized as a single exception class with a focused initializer. Nesting: Minimal, limited to the class and method. Clarity of intent: The descriptive class name, AttributeError inheritance, and docstring clearly communicate its purpose, though the docstring's opening sentence is grammatically awkward. Code length: Short and appropriately scoped; the documentation adds useful context without excessive detail. Action granularity: Each statement performs one action, making initialization easy to follow. Reading flow: Natural progression from documentation to message creation, superclass initialization, and message storage. Minor spacing and wording improvements would polish an already highly readable snippet.

Run 3

Code Structure: A logically organized exception class with documentation followed by a short initializer. Nesting: Minimal, limited to the class and its method. Clarity of intent: The class name, AttributeError inheritance, and docstring clearly communicate immutable-object modification errors, though the docstring's opening sentence is grammatically awkward. Code length: Concise, with documentation providing useful context; storing the message separately is slightly redundant but understandable. Action granularity: Each statement performs one clear action. Reading flow: Natural progression from purpose to implementation, with consistent indentation and spacing.