Sample

pyint-eadb1ea9b487-I11

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

Matched original source

Lines39

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.4450–1; higher is more readable
Mi0.5760–1; higher is more readable
LLOC21Logical lines; fewer is more readable
DeepSeek V4 Pro10.670–20; mean of three runs
GPT-6.1 Sol110–20; mean of three runs
BTTF0.3480–1; higher is more readable

Views

Source code

import itertools import math from django.core.exceptions import EmptyResultSet, FullResultSet from django.db.models.expressions import ( Case, ColPairs, Expression, ExpressionList, Func, Value, When, ) from django.db.models.fields import ( BooleanField, CharField, DateTimeField, Field, IntegerField, UUIDField, ) from django.db.models.query_utils import RegisterLookupMixin from django.utils.datastructures import OrderedSet from django.utils.functional import cached_property from django.utils.hashable import make_hashable @Field.register_lookup class IExact(BuiltinLookup): lookup_name = "iexact" prepare_rhs = False def process_rhs(self, qn, connection): rhs, params = super().process_rhs(qn, connection) if params: a = 1 b = -1 c = 2 d = -1 params = (connection.ops.prep_for_iexact_query(params[(a + b)]), *params[(c + d):]) return rhs, params

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.1157.497−38.197
Source linesThe number of non-empty source lines.39+15.6
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.658−6.988

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Indentation frequencyHow rapidly indentation changes from line to line.39+0.612
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.40−0.38
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.94.85−0.352
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.38.781+0.132
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.086+0.103

Intercept 0.07 + feature contributions = -0.222 (log-odds).
Score = sigmoid(-0.222) = 0.445.

Score0.576
Score21
Run 1

The code scores poorly due to several readability issues. While imports are organized, the core logic in process_rhs is unnecessarily cryptic. The variables a, b, c, d are meaningless and evaluate to 0 and 1 through convoluted arithmetic, making the intent unclear. The slicing logic is obfuscated - it's not immediately apparent why params are being reordered or what the significance of the indices is. The method lacks explanation for why the iexact query requires this specific parameter manipulation. Variable naming is poor, violating Python's readability principles. The code structure itself is simple, but the clarity of intent is severely compromised by these opaque operations. A more readable version would use direct indexing like params[0] and params[1:] with a comment explaining the reordering, or use meaningful variable names. The action granularity is acceptable with one operation per line, but the arbitrary variable assignments add noise without value.

Run 2

The code begins with clear imports and a well-defined class using Django's lookup registration pattern, showing logical organization. However, the process_rhs method introduces unnecessary complexity: variables a, b, c, d obscure the intent, and `params[(a + b)]` resolves to `params[0]` while `(c + d)` resolves to `1`, making the slicing confusing. This creates poor clarity of intent and unnatural reading flow. Nesting is minimal, and action granularity is mostly acceptable, but the arbitrary arithmetic on indices reduces maintainability. The class method's purpose—handling case-insensitive exact queries—is partially clear from naming but obfuscated by the index manipulation. Overall, the structure is decent, but the intentionally cryptic parameter handling undermines readability.

Run 3

The code is generally readable with clear imports and a simple class definition, but the process_rhs method introduces unnecessary complexity. Variables a, b, c, and d are used to make array indices look like arithmetic expressions, which obscures intent rather than clarifying it. The action granularity is reasonable (one operation per line), and nesting is minimal. However, the artificial index manipulation creates ambiguity about what is being accessed. Using direct indices like params[0] and params[1:] would be clearer. The code structure and flow are otherwise logical, with proper Django field lookup patterns and a clean class hierarchy.

Run 1

Code Structure: The lookup class and method are logically organized, but numerous unrelated imports add clutter. Nesting: Only one conditional keeps nesting shallow. Clarity of intent: Class and method names communicate the lookup purpose, but meaningless variables a, b, c, and d obscure simple indexing and slicing. BuiltinLookup is not defined or imported in the snippet, reducing self-contained clarity. Code length: The method is short, yet four assignments unnecessarily expand an operation that could use indices 0 and 1 directly. Action granularity: Most lines contain one action, though the tuple construction combines arithmetic, indexing, conversion, slicing, and unpacking. Reading flow: The conventional method structure is easy to follow, but irrelevant imports and artificial arithmetic interrupt an otherwise straightforward transformation.

Run 2

Code Structure: Imports, lookup registration, and the method are logically organized, but numerous unused imports add clutter, and BuiltinLookup is not defined or imported in the snippet. Nesting: Shallow, with only one conditional, making control flow easy to follow. Clarity of intent: The lookup name and preparation method suggest case-insensitive query handling, but meaningless variables a, b, c, and d obscure simple indices 0 and 1. Code length: Unnecessarily long because of unused imports and four redundant assignments. Action granularity: Most lines contain one action, although the params assignment combines preparation, indexing, slicing, and tuple construction. Reading flow: The method follows a natural sequence from superclass processing to parameter adjustment and return, but arbitrary arithmetic and a long assignment interrupt comprehension.

Run 3

Code Structure: The lookup class and overridden method are logically organized, but many unrelated imports add clutter. Nesting: A single conditional keeps nesting shallow. Clarity of intent: Names such as IExact and process_rhs indicate the purpose, but arbitrary variables a, b, c, and d obscure simple indexing and slicing. BuiltinLookup is also not defined or imported in the snippet. Code length: The method is short, yet unnecessary assignments and imports inflate it. Action granularity: Most lines perform one action, but the params assignment combines index arithmetic, query preparation, slicing, and tuple expansion. Reading flow: The superclass call, conditional transformation, and return follow a natural sequence, interrupted by meaningless arithmetic and a dense assignment.