Sample

pyint-1815010b9f6e-I05

Rewrite eligible decimal integer literals in hexadecimal notation

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 highly readable. It has clear structure with logical imports and a well-documented class. The `_CacheHashWrapper` class has a single, focused responsibility and its purpose is explained succinctly in the docstring. Nesting is minimal. The `__reduce__` method uses keyword arguments for clarity. Function names and comments convey intent effectively. The code is concise and follows Python conventions, making the reading flow natural and easy to follow.

Run 3

The code is well-structured and readable. It begins with a clear import section, including standard library, typing, and relative imports, which aids understanding of dependencies. The class `_CacheHashWrapper` is logically placed with a docstring explaining its purpose and rationale. Nesting is minimal; the class has a single method with no deep indentation. The intent is clearly conveyed through naming and comments. Code length is appropriate for the functionality. Action granularity is good—each line performs a distinct operation. The reading flow is natural, moving from imports to class definition to method. Minor deductions: the use of `# noqa: B008` and default argument `_none_constructor=type(None)` could be slightly clearer, and the import alias `PY_3_11_PLUS` etc. are not used in this snippet, but these do not significantly harm readability.

Run 1

Code Structure: Imports precede a focused class definition, providing logical organization, though the many imports are unused in this excerpt. Nesting: Minimal nesting makes the code 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__ signature requires some Python knowledge. Code length: The implementation is concise, with documentation proportionate to the non-obvious behavior. Action granularity: Each import and the single return statement occupy separate lines without compounded actions. Reading flow: The progression from imports to explanation to implementation is natural, although an additional blank line before the top-level class would improve conventional formatting.

Run 2

Code Structure: Imports are grouped sensibly, followed by a focused class with a single method. Nesting: Minimal nesting makes the implementation easy to scan. Clarity of intent: The descriptive class name and detailed docstring clearly explain why cached hashes reset during copying or pickling; the specialized __reduce__ signature requires some Python knowledge. Code length: The implementation is concise, though the extensive imports appear disproportionate to this excerpt. Action granularity: Each statement performs one clear action, with no compressed multi-action lines. 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, although many imports are unused in this excerpt. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The class name and detailed docstring clearly explain why cached hashes reset during copying or pickling; the special method and default arguments require some Python-specific knowledge. Code length: The implementation is concise, and the documentation provides useful context without excessive detail. Action granularity: Each line performs a single action, with a straightforward tuple return. Reading flow: The progression from imports to explanation to implementation is natural, though the large import block slightly outweighs the small amount of executable code.