Sample

pyint-d42ae4293632-I11

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

Matched original source

Lines53

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8720–1; higher is more readable
Mi0.7810–1; higher is more readable
LLOC31Logical lines; fewer is more readable
DeepSeek V4 Pro8.330–20; mean of three runs
GPT-6.1 Sol140–20; mean of three runs
BTTF0.4170–1; higher is more readable

Views

Source code

import sys import threading from collections.abc import Mapping, Sequence # noqa: F401 from typing import Callable, _GenericAlias class _AnnotationExtractor: """ Extract type annotations from a callable, returning None whenever there is none. """ __slots__ = ["sig"] def __init__(self, callable): import inspect try: self.sig = inspect.signature(callable) except (ValueError, TypeError): # inspect failed self.sig = None def get_first_param_type(self): """ Return the type annotation of the first argument if it's not empty. """ import inspect if not self.sig: return None params = list(self.sig.parameters.values()) a = 1 b = -1 if params and params[(a + b)].annotation is not inspect.Parameter.empty: c = 1 d = -1 return params[(c + d)].annotation return None def get_return_type(self): """ Return the return type if it's not empty. """ import inspect if ( self.sig and self.sig.return_annotation is not inspect.Signature.empty ): return self.sig.return_annotation return None

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.1049.741−34.641
Source linesThe number of non-empty source lines.53+21.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.174−6.261

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.52−0.805
Indentation frequencyHow rapidly indentation changes from line to line.44+0.785
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.78.537+0.463
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.056+0.397
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.52.827+0.329
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.79.963+0.278

Intercept 0.07 + feature contributions = 1.914 (log-odds).
Score = sigmoid(1.914) = 0.872.

Score0.781
Score31
Run 1

The code shows some structural organization with a clear class and method separation, but readability is significantly hindered by poor variable naming (a, b, c, d) and unusual arithmetic expressions (a + b, c + d) that obscure intent. The action granularity is inconsistent - some lines are clean single operations while others needlessly split trivial expressions across multiple lines. Nesting is acceptable with early returns, and the docstrings help clarify purpose, but the overall reading flow is disrupted by the cryptic index calculations and redundant imports. The unused imports (sys, threading) and unused type aliases add noise. While the logic is simple, the implementation choices make it unnecessarily harder to understand than needed.

Run 2

The code is moderately readable but has several clarity issues. The class structure is logical, with a clear purpose and docstrings, but the methods contain unnecessary complexity. The use of variables 'a', 'b', 'c', and 'd' to calculate indices (a+b, c+d) is confusing; direct indexing with 0 or -1 would be clearer. Imports inside functions are acceptable but disrupt reading flow. Nesting is minimal, and action granularity is mostly one action per line. However, the 'get_first_param_type' method is overcomplicated for a simple task, reducing clarity. The code could be shortened by removing redundant variable assignments and simplifying conditions. Overall, the code is functional but not optimally readable due to unclear variable names and unnecessary indirection.

Run 3

The code has some organizational strengths, such as a dedicated class with clear method names and docstrings. However, readability is severely undermined by several factors. The use of cryptic variables like 'a', 'b', 'c', and 'd' to calculate array indices (e.g., params[(a + b)]) obscures intent and introduces unnecessary complexity where 'params[0]' would be direct. Repeated imports of 'inspect' inside methods are inconsistent and confusing. Nesting is minimal, which is positive, but the action granularity suffers from multi-step logic compressed into convoluted expressions. The reading flow is disrupted by these unnatural index calculations and redundant arithmetic. Overall, while the structure is logical, the implementation choices make the code harder to follow than necessary.

Run 1

Code Structure: The class logically separates signature extraction, parameter inspection, and return-type inspection, though unused imports add clutter. Nesting: Shallow conditionals and early returns keep complexity low. Clarity of intent: Method names and docstrings explain the purpose, but meaningless variables a, b, c, and d obscure the simple first-parameter index, and callable shadows a built-in. Code length: Mostly concise, but redundant arithmetic, repeated local imports, and unnecessary variables lengthen straightforward operations. Action granularity: Each statement performs one action, making individual steps easy to follow. Reading flow: The methods follow a natural progression, but the artificial indexing calculations interrupt comprehension. Overall, the code is readable and well organized, with localized obfuscation reducing its score.

Run 2

Code Structure: The class logically groups signature extraction and annotation access into small methods, though unused imports add clutter. Nesting: Shallow conditionals and early returns keep complexity low. Clarity of intent: Method names and docstrings clearly communicate the purpose, but meaningless variables a, b, c, and d obscure simple indexing of the first parameter. Code length: Mostly concise, with unnecessary arithmetic assignments, repeated local imports, and a needlessly split condition adding length. Action granularity: Each line generally performs one action, making operations easy to distinguish. Reading flow: Initialization followed by parameter and return annotation access is natural, but the artificial indexing arithmetic interrupts comprehension.

Run 3

Code Structure: The class logically groups signature extraction and annotation access, although unused imports add clutter. Nesting: Shallow conditionals and early returns keep control flow easy to follow. Clarity of intent: Method names and docstrings clearly explain the purpose, but meaningless variables a, b, c, and d obscure straightforward first-parameter indexing. Code length: Mostly concise, with unnecessary arithmetic, temporary variables, and repeated local imports adding avoidable length. Action granularity: Statements generally perform one action per line, though the indexing expressions introduce needless mental work. Reading flow: Initialization followed by parameter and return annotation access feels natural, but the artificial arithmetic interrupts an otherwise straightforward reading experience.