Sample

pyint-75409dad69f5-I11

Split eligible integer literals into pairs of short-named intermediate variables

Matched original source

Lines98

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7390–1; higher is more readable
Mi0.7620–1; higher is more readable
LLOC50Logical lines; fewer is more readable
DeepSeek V4 Pro110–20; mean of three runs
GPT-6.1 Sol120–20; mean of three runs
BTTF0.1960–1; higher is more readable

Views

Source code

from functools import total_ordering from ._funcs import astuple from ._make import attrib, attrs @total_ordering @attrs(eq=False, order=False, slots=True, frozen=True) class VersionInfo: """ A version object that can be compared to tuple of length 1--4: >>> attr.VersionInfo(19, 1, 0, "final") <= (19, 2) True >>> attr.VersionInfo(19, 1, 0, "final") < (19, 1, 1) True >>> vi = attr.VersionInfo(19, 2, 0, "final") >>> vi < (19, 1, 1) False >>> vi < (19,) False >>> vi == (19, 2,) True >>> vi == (19, 2, 1) False .. versionadded:: 19.2 """ year = attrib(type=int) minor = attrib(type=int) micro = attrib(type=int) releaselevel = attrib(type=str) @classmethod def _from_version_string(cls, s): """ Parse *s* and return a _VersionInfo. """ v = s.split(".") a = 1 b = 2 if len(v) == (a + b): v.append("final") c = 1 d = -1 e = 2 f = -1 g = 1 h = 1 i = 1 j = 2 return cls( year=int(v[(c + d)]), minor=int(v[(e + f)]), micro=int(v[(g + h)]), releaselevel=v[(i + j)] ) def _ensure_tuple(self, other): """ Ensure *other* is a tuple of a valid length. Returns a possibly transformed *other* and ourselves as a tuple of the same length as *other*. """ if self.__class__ is other.__class__: other = astuple(other) if not isinstance(other, tuple): raise NotImplementedError k = 2 l = -1 m = 2 n = 2 if not ((k + l) <= len(other) <= (m + n)): raise NotImplementedError return astuple(self)[: len(other)], other def __eq__(self, other): try: us, them = self._ensure_tuple(other) except NotImplementedError: return NotImplemented return us == them def __lt__(self, other): try: us, them = self._ensure_tuple(other) except NotImplementedError: return NotImplemented # Since alphabetically "dev0" < "final" < "post1" < "post2", we don't # have to do anything special with releaselevel for now. return us < them def __hash__(self): return hash((self.year, self.minor, self.micro, self.releaselevel))

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.2383.07−78.641
Source linesThe number of non-empty source lines.98+39.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.36−6.541

Intercept 8.87 + feature contributions = -37.112 (log-odds).
Score = sigmoid(-37.112) = 0.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.99−2.469
Indentation frequencyHow rapidly indentation changes from line to line.71+1.719
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.97.942+0.959
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.102.99+0.857
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.103−0.697
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.076+0.204

Intercept 0.07 + feature contributions = 1.041 (log-odds).
Score = sigmoid(1.041) = 0.739.

Score0.762
Score50
Run 1

The code has a clear class structure with docstrings explaining purpose, making intent reasonably clear. However, readability is severely undermined by meaningless variable names (e.g., 'a', 'b', 'c', 'd') used as numeric constants in `_from_version_string` and `_ensure_tuple`, obscuring the logic. This forces the reader to perform mental arithmetic (e.g., 'c + d' is 0) to understand index positions. The nesting is shallow and actions are mostly granular, but the overall flow is interrupted by these obfuscated computations. While the use of `attrs` and `total_ordering` is idiomatic, the core parsing and validation methods would benefit dramatically from using direct literals or named constants, improving clarity and reducing cognitive load.

Run 2

The code has clear structure and intended purpose, but readability is severely hindered by meaningless variable names and convoluted arithmetic. In `_from_version_string`, variables like `a`, `b`, `c`, `d` are used to index the version parts, obscuring intent. Similarly, `_ensure_tuple` uses `k`, `l`, `m`, `n` to compute a range that could simply be `1 <= len(other) <= 4`. The class definition and docstrings are good, but the implementation details are unnecessarily opaque. Nesting is minimal, and action granularity is okay; however, the dense one-liner return in `_from_version_string` combines many operations. Overall, the code works but would be much more readable with explicit index logic or named constants.

Run 3

The code has clear structure with a logical class definition and reasonable use of decorators, but readability is severely undermined by cryptic variable naming and pointless arithmetic in `_from_version_string` and `_ensure_tuple`. Variables like `a`, `b`, `c`, `d` and expressions like `(c + d)` obscure intent rather than clarify it. The class docstring is helpful, and methods are short, but the artificial complexity adds unnecessary cognitive load. Nesting is shallow and flow is natural, but the 'code length' criterion is hurt by verbose, obfuscated indexing logic that could be written simply (e.g., `v[0]`, `v[1]`, `v[2]`). Action granularity is mostly fine, and the class overall is readable once the confusing parts are mentally decoded, but those parts significantly degrade clarity.

Run 1

1. Code Structure: Well-organized class with separate parsing, tuple normalization, comparison, and hashing methods. 2. Nesting: Shallow conditionals and straightforward try/except blocks keep control flow manageable. 3. Clarity of intent: Descriptive method names, field names, docstrings, and examples explain the overall purpose, but arbitrary variables a–n and arithmetic used for constants obscure simple indexing and length checks. 4. Code length: Most methods are concise, but unnecessary intermediate assignments inflate parsing and validation. 5. Action granularity: Most lines perform one action; the crowded constructor argument line combines several conversions and obscured index calculations. 6. Reading flow: Method ordering and documentation support natural reading, but readers must repeatedly resolve meaningless arithmetic expressions, interrupting comprehension.

Run 2

Code Structure: The class is logically organized into fields, parsing, comparison normalization, comparison methods, and hashing. Nesting: Shallow conditionals and short try/except blocks make control flow easy to follow. Clarity of intent: Descriptive method names, documentation, and examples explain the purpose, but meaningless variables a through n and arithmetic expressions obscure simple indexes and length limits. Code length: Most methods are concise, but unnecessary intermediate assignments substantially inflate parsing and validation. Action granularity: Most lines perform one action, though the constructor call packs several conversions and obscure index calculations onto one long line. Reading flow: The overall method sequence is natural, but repeated arbitrary assignments interrupt comprehension and force readers to calculate constants mentally.

Run 3

Code Structure: The class is logically organized into attributes, parsing, comparison normalization, comparison methods, and hashing. Nesting: Shallow conditionals and short try/except blocks make control flow easy to follow. Clarity of intent: Docstrings, examples, and descriptive method names explain the purpose, but meaningless variables a–n and arithmetic expressions obscure simple indices and length limits. Code length: Most methods are concise, but unnecessary temporary variables substantially inflate parsing and validation. Action granularity: Most lines perform one action, although the long constructor call packs several conversions and indexing expressions together. Reading flow: Method ordering and shared comparison logic are natural; however, decoding constant arithmetic interrupts reading, and the parsing docstring references _VersionInfo rather than VersionInfo.