Sample

pyint-53b9f6091a29-I03

Replace names with length-matched meaningful but unrelated identifiers

Matched original source

Lines43

Scores

MethodScoreScale
Posnett0.1060–1; higher is more readable
Dorn0.770–1; higher is more readable
Mi0.6670–1; higher is more readable
LLOC20Logical lines; fewer is more readable
DeepSeek V4 Pro17.330–20; mean of three runs
GPT-6.1 Sol16.670–20; mean of three runs
BTTF0.7290–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, currentBalance=type(None), total=()): # noqa: B008 return currentBalance, total

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.748−7.122

Intercept 8.87 + feature contributions = -2.132 (log-odds).
Score = sigmoid(-2.132) = 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.617
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.44−0.522
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.75.977+0.447
Indentation frequencyHow rapidly indentation changes from line to line.33+0.404
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.70.818+0.338
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.33−0.336
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.42.883+0.19

Intercept 0.07 + feature contributions = 1.208 (log-odds).
Score = sigmoid(1.208) = 0.77.

Score0.667
Score20
Run 1

This code is highly readable. The structure is logical: imports are grouped clearly by standard library, third-party, and local modules, with explicit relative imports for internal dependencies. The single class defined is small, focused, and accompanied by a clear docstring that explains its purpose and rationale. Nesting is essentially flat—only one method exists and it is concise. Intent is very clear: the class wraps int to ensure hash values reset on copy/pickle, with rationale explicitly documented. Code length is appropriate; no unnecessary bloat or over-engineering. Action granularity is well-managed, with each import and the single method body containing distinct operations. Reading flow is natural—the reader progresses from imports to a single well-encapsulated class without jumping around. Minor deductions only because the method signature uses non-obvious parameter names and a noqa comment, which slightly interrupts flow, but this is justified for the pickle behavior.

Run 2

The code is well-structured and readable overall. It has a clear module-level organization with grouped imports and a focused class definition. Nesting is minimal, intent is clear from the class name and docstring, and the method is concise with one action per line. However, readability is slightly reduced by the unusual use of default arguments in __reduce__ (currentBalance=type(None), total=()) which is non-standard and could confuse readers, and the 'noqa: B008' comment adds minor clutter. Variable names like 'currentBalance' and 'total' are not descriptive for the intent of resetting hash values. The docstring is helpful but the logic of returning a tuple that effectively becomes None on pickling is not immediately obvious without deeper knowledge of Python's pickle protocol.

Run 3

The code is highly readable, well-structured, and demonstrates clear intent. It uses standard import organization, readable type hints, and a concise class definition. The single class `_CacheHashWrapper` is flat with only one method, avoiding excessive nesting. The method implements one clear action—returning a tuple for pickling. Naming is descriptive (e.g., `_CacheHashWrapper`, `__reduce__`). The use of `# noqa: B008` and comments shows attention to linting and rationale. Although the example is a partial module, the visible portion is logically organized, with only one small class to evaluate. The inclusion of `from __future__ import annotations` and careful imports suggests maintainability. Minor deductions for slightly dense import block and the unusual default argument `currentBalance=type(None)` with a noqa comment, but these don't significantly impair readability.

Run 1

Code Structure: Imports are grouped sensibly, followed by a focused class, although most 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. However, the parameter names currentBalance and total are misleading for serialization behavior, and the default type(None) requires familiarity with Python's reduction protocol. Code length: The implementation is concise; the longer docstring provides useful context rather than unnecessary repetition. Action granularity: Each statement performs a single action. Reading flow: The progression from imports to documentation to implementation is natural, though the extensive import block distracts from the small class and spacing between top-level sections could be improved.

Run 2

Code Structure: Imports precede a focused class, providing logical organization, although many imports are unused in this excerpt. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The descriptive class name and detailed docstring clearly explain why cached hashes reset during serialization or copying. However, the parameter names currentBalance and total are unrelated to their roles in __reduce__, creating unnecessary ambiguity. Code length: The implementation is concise; the docstring adds useful context rather than excessive detail. Action granularity: Each line performs a single clear action. Reading flow: The progression from imports to documentation to implementation is natural, though the large import block distracts from the small class, and additional spacing between import groups would improve readability.

Run 3

Code Structure: Imports are grouped logically, followed by a small, focused class, though many imports are unused in this excerpt. Nesting: Minimal, with only a class and its method. Clarity of intent: The docstring clearly explains why cached hashes reset during copying or pickling, but parameter names currentBalance and total are unrelated to serialization and obscure the method's behavior. Code length: The implementation is concise, with documentation providing useful context. Action granularity: Each line performs one clear action. Reading flow: Organization is natural, although the extensive import section delays the relevant code, and the misleading parameter names interrupt comprehension.