Sample

pyint-947b12771942-I13

Lower every eligible synchronous for loop to a while loop

Matched original source

Lines43

Scores

MethodScoreScale
Posnett0.1060–1; higher is more readable
Dorn0.7610–1; higher is more readable
Mi0.7070–1; higher is more readable
LLOC20Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.7520–1; higher is more readable

Views

Source code

from __future__ import annotations import abc import contextlib import enum import itertools import linecache import sys import types import unicodedata import weakref from collections.abc import Callable, Mapping from functools import cached_property from typing import Any, NamedTuple, TypeVar from . import _compat, _config, setters from ._compat import ( PY_3_11_PLUS, PY_3_13_PLUS, _AnnotationExtractor, _get_annotations, _lazy_is_generator, get_generic_base, ) from .exceptions import ( DefaultAlreadySetError, FrozenInstanceError, NotAnAttrsClassError, UnannotatedAttributeError, ) class _CacheHashWrapper(int): """ An integer subclass that pickles / copies as None This is used for non-slots classes with ``cache_hash=True``, to avoid serializing a potentially (even likely) invalid hash value. Since `None` is the default value for uncalculated hashes, whenever this is copied, the copy's value for the hash should automatically reset. See GH #613 for more details. """ def __reduce__(self, _none_constructor=type(None), _args=()): # noqa: B008 return _none_constructor, _args

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.638.793−21.08
Source linesThe number of non-empty source lines.43+17.2
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.746−7.119

Intercept 8.87 + feature contributions = -2.129 (log-odds).
Score = sigmoid(-2.129) = 0.106.

Feature contributions

FeatureValueContribution
(log-odds)
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.033+0.619
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.44−0.522
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.75.364+0.412
Indentation frequencyHow rapidly indentation changes from line to line.33+0.404
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.33−0.336
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.977+0.32
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.42.913+0.19

Intercept 0.07 + feature contributions = 1.157 (log-odds).
Score = sigmoid(1.157) = 0.761.

Score0.707
Score20
Run 1

The code is generally well-structured and readable. It demonstrates clear organization with logical import grouping (stdlib, third-party, local), explicit future annotations import, and a focused single-class definition. The class has a clear docstring explaining its purpose and non-obvious behavior, which significantly improves clarity. Nesting is flat with no conditional logic. Action granularity is appropriate - each line performs one clear operation. The reading flow is natural: imports, then class definition, then method. The use of type hints (int subclass, annotations) adds to clarity. Minor deductions: the import section is somewhat long but follows Python conventions. The default argument pattern (_none_constructor=type(None), _args=()) is slightly unconventional and may require readers to pause. The blanket noqa comment suppresses linting checks without specifying which rule is being disabled. Overall, this is readable code appropriate for a library implementation.

Run 2

The code is well-structured with clear separation of imports, a single class definition, and a concise docstring explaining non-obvious behavior. Nesting is minimal - the class has one method with no nested blocks. Intent is clearly documented through the class name, docstring, and method purpose. Code length is appropriate: the module header imports what's needed and the class implements focused functionality. Action granularity is good with each operation on its own line. Reading flow follows a natural progression from imports to class definition to method implementation. The only minor deductions are for the somewhat cryptic `__reduce__` implementation (though documented) and the `# noqa: B008` comment which assumes familiarity with linting rules.

Run 3

The code is well-structured and highly readable. Imports are organized logically, with clear separation between standard library, third-party, and local modules. The single class defined has a clear, documented purpose with a concise docstring explaining the rationale. Nesting is minimal — there is only one method with a single return statement. Intent is explicit through descriptive naming and comments referencing a GitHub issue for context. Code length is appropriate: no unnecessary verbosity or redundancy. Action granularity is good, with each line performing a distinct operation. The reading flow is natural, moving from imports to class definition to method details. Minor deductions: `_none_constructor` and `_args` as default arguments may be slightly opaque without deeper comprehension, and the import block is long. Overall, this code adheres to clean coding practices and is easy to follow.

Run 1

Code Structure: Imports are grouped logically, followed by a small, focused class. Nesting: Minimal nesting makes the implementation easy to scan. Clarity of intent: The class name and detailed docstring clearly explain why cached hashes reset during copying or pickling; the specialized __reduce__ defaults require some Python knowledge. Code length: The implementation is concise, although the import block is large relative to the displayed functionality. Action granularity: Each import or operation occupies its own line, with a single return in the method. Reading flow: The progression from imports to documentation to implementation is natural, though an extra blank line before the top-level class would improve visual separation.

Run 2

Code Structure: Imports and the class are logically organized, though the extensive import block adds overhead to this small excerpt. Nesting: The code is flat, with only a class and a single method. Clarity of intent: The descriptive class name and detailed docstring clearly explain why cached hashes reset during copying and pickling; the specialized __reduce__ signature and captured defaults require some Python knowledge. Code length: The implementation is concise, and the documentation provides useful context rather than unnecessary repetition. Action granularity: Each statement performs a single clear action. Reading flow: The progression from imports to explanation to implementation is natural, although additional blank lines between import groups and before the class would improve visual separation.

Run 3

Code Structure: Imports are grouped logically, followed by a small, focused class. Nesting: Minimal nesting makes the implementation easy to scan. Clarity of intent: The descriptive class name and thorough docstring explain why cached hashes reset during copying or pickling, although the __reduce__ defaults require familiarity with Python serialization. Code length: The implementation is concise; the import list is substantial relative to the shown functionality. Action granularity: Each line performs one clear action, with a straightforward tuple return. Reading flow: The progression from imports to documentation to implementation is natural, though additional blank lines between import groups and before the class would improve visual separation.