Sample

pyint-07af6c6cb0aa-I05

Rewrite eligible decimal integer literals in hexadecimal notation

Matched original source

Lines44

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8450–1; higher is more readable
Mi0.5260–1; higher is more readable
LLOC23Logical lines; fewer is more readable
DeepSeek V4 Pro16.330–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.4860–1; higher is more readable

Views

Source code

from django.db.backends.postgresql.psycopg_any import is_psycopg3 from django.db.models import ( CharField, Expression, Field, FloatField, Func, Lookup, TextField, Value, ) from django.db.models.expressions import CombinedExpression, register_combinable_fields from django.db.models.functions import Cast, Coalesce from django.utils.regex_helper import _lazy_re_compile from .utils import CheckPostgresInstalledMixin class LexemeCombinable: BITAND = "&" BITOR = "|" def _combine(self, other, connector, reversed): if not isinstance(other, LexemeCombinable): raise TypeError( "A Lexeme can only be combined with another Lexeme, " f"got {other.__class__.__name__}." ) if reversed: return CombinedLexeme(other, connector, self) return CombinedLexeme(self, connector, other) # On Combinable, these are not implemented to reduce confusion with Q. In # this case we are actually (ab)using them to do logical combination so # it's consistent with other usage in Django. def __or__(self, other): return self._combine(other, self.BITOR, False) def __ror__(self, other): return self._combine(other, self.BITOR, True) def __and__(self, other): return self._combine(other, self.BITAND, False) def __rand__(self, other): return self._combine(other, self.BITAND, True)

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.1269.981−41.909
Source linesThe number of non-empty source lines.44+17.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.639−6.959

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.41+0.681
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.86.911+0.598
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.45−0.557
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.064+0.317
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.43.852+0.203
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.86.956−0.018

Intercept 0.07 + feature contributions = 1.693 (log-odds).
Score = sigmoid(1.693) = 0.845.

Score0.526
Score23
Run 1

The code demonstrates good structure with clear class organization and logical method grouping. Nesting is minimal, with only a single level inside _combine for validation. Intent is evident: implementing bitwise combinable lexemes for PostgreSQL full-text search. The code is appropriately concise — helper methods reuse _combine to avoid duplication. Each action is separated per line, maintaining granularity. Reading flow follows a natural pattern: constants, core logic, then operator overloads. The type check and error message are clear. Minor deductions: no type hints, and the comment about abusing operators could be slightly clearer for readers unfamiliar with Django internals. Overall, readable code with strong maintainability.

Run 2

The code demonstrates clear structure and good organization, with a single class containing related methods. Nesting is minimal—only a simple if-statement inside _combine. Intent is obvious: implementing bitwise operators for lexeme combination. The code is concise, with each method performing one action. Reading flow is natural, moving from constants to the core _combine logic, then to operator overloads. The type check and error message are clear. Minor deductions: the comment about 'abusing' operators is slightly informal, and the reversed parameter logic could use a brief explanation, but these don't significantly impact readability. Overall, this is well-structured, maintainable code that follows Python conventions.

Run 3

The code is well-structured with a clear, single-purpose class. It uses flat nesting, minimal branching, and one action per line, which aids readability. The methods are concise and logically organized, with consistent parameter ordering and symmetric bitwise operator implementations. Type checking is handled explicitly with a clear error message. The explanatory comment about abusing operators is helpful for understanding intent. Minor deductions: the repeated _combine calls add slight verbosity, and the reversed-argument handling could be slightly more evident, but overall the code is highly readable and maintainable.

Run 1

Code Structure: The class cleanly groups operator constants, shared combination logic, and operator overloads, although several imports are unused in the provided snippet. Nesting: Minimal; simple conditionals and early returns keep control flow flat. Clarity of intent: Descriptive names, an informative error message, and a contextual comment explain lexeme combination, though the boolean reversal argument and bitwise-named constants require some interpretation. Code length: Concise, with shared logic avoiding duplication across overloads. Action granularity: Each statement performs one clear action, and multiline formatting improves readability. Reading flow: Definitions progress naturally from constants to implementation to public operators; additional spacing between imports and the class would slightly improve presentation.

Run 2

Code Structure: The class is logically organized, with operator constants, a shared combination helper, and grouped operator methods. Nesting: Shallow conditionals and early returns keep control flow simple. Clarity of intent: Names, the descriptive type error, and the explanatory comment make logical lexeme combination clear, though BITAND/BITOR terminology and the parameter named reversed introduce minor ambiguity. Code length: The implementation is concise and avoids duplication through _combine; several imports appear unused in this excerpt. Action granularity: Each statement performs a single clear action. Reading flow: The progression from validation to operand ordering to operator wrappers is natural, although understanding CombinedLexeme requires external context.

Run 3

Code Structure: The class logically groups operator constants, shared combination logic, and operator overloads. Nesting: Shallow conditionals and early returns keep control flow simple. Clarity of intent: Descriptive names, an informative error message, and a contextual comment explain lexeme combination, although the boolean 'reversed' parameter and positional True/False arguments require some interpretation. Code length: Methods are concise, with duplication minimized through _combine; several imports are unused in the shown snippet and add visual clutter. Action granularity: Each statement performs a single clear action, and multiline formatting improves readability. Reading flow: Constants precede implementation, followed by thin operator wrappers, creating a natural progression. Minor spacing inconsistencies and reliance on Django-specific concepts slightly reduce accessibility.