Sample

pyint-794ee150d6a4-I05

Rewrite eligible decimal integer literals in hexadecimal notation

Matched original source

Lines21

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.6040–1; higher is more readable
Mi0.6690–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro17.330–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.5720–1; higher is more readable

Views

Source code

import operator from functools import reduce from django.core.exceptions import EmptyResultSet, FullResultSet from django.db.models.expressions import Case, When from django.db.models.functions import Mod from django.db.models.lookups import Exact from django.utils import tree from django.utils.functional import cached_property class ExtraWhere: # The contents are a black box - assume no aggregates or windows are used. contains_aggregate = False contains_over_clause = False def __init__(self, sqls, params): self.sqls = sqls self.params = params def as_sql(self, compiler=None, connection=None): sqls = ["(%s)" % sql for sql in self.sqls] return " AND ".join(sqls), list(self.params or ())

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.780.484−25.756
Source linesThe number of non-empty source lines.21+8.4
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.653−6.979

Intercept 8.87 + feature contributions = -15.465 (log-odds).
Score = sigmoid(-15.465) = 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
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
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.78+0.361
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.066+0.303
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.22+0.257
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.20.797−0.119
Indentation frequencyHow rapidly indentation changes from line to line.20−0.045

Intercept 0.07 + feature contributions = 0.421 (log-odds).
Score = sigmoid(0.421) = 0.604.

Score0.669
Score17
Run 1

The code is clean and readable. Structure is logical: a simple class encapsulates two data attributes and one rendering method. Nesting is flat, with only a list comprehension. Intent is clear from descriptive names ('ExtraWhere', 'sqls', 'params') and a helpful comment explaining constraints. The code is concise without unnecessary boilerplate. Action granularity is fine, with each step in 'as_sql' separated. Reading flow is natural. Minor deductions: the 'compiler' and 'connection' parameters are unused, and the comprehension could be split for clarity, but overall readability is high.

Run 2

The code is highly readable. It has a clear, minimal class structure with a well-defined purpose. Nesting is essentially flat. Intent is explicit via comments and naming. Length is concise; no unnecessary code. Action granularity is good — one logical action per line (the list comprehension and join in as_sql are compact but clear). Reading flow is natural: class docstring explaining constraints, simple __init__, and a clear as_sql method. Minor deduction only because the list comprehension and formatting could be expanded for slightly improved clarity, but overall very clean.

Run 3

The code is well-structured and highly readable. It has a clear class definition with a single responsibility and minimal nesting. The class attributes are documented succinctly with a comment, clarifying that aggregates/windows are not handled. The __init__ method is concise and directly assigns instance variables. The as_sql method demonstrates good action granularity: formatting each SQL snippet into parentheses is done in one line with a list comprehension, followed by a clear join operation. The flow is natural—starting with class-level metadata, moving to initialization, then providing the core SQL generation method. The use of a list comprehension keeps the code concise without sacrificing clarity. Variable names like sqls, params, and self.sqls are self-explanatory. Overall, the code is clean, purposeful, and easy to follow. Minor deductions only because the exact meaning of ExtraWhere as a concept is slightly domain-specific, but within its context it is clear.

Run 1

Code Structure: Imports and a small, focused class provide logical organization, though several imports are unused in this snippet. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The class stores SQL fragments and parameters, then combines the fragments with AND; the comment explains the aggregate and window assumptions. Names such as sqls are slightly terse. Code length: The implementation is concise without unnecessary logic. Action granularity: Statements generally perform one clear action; the return expression combines formatting and parameter normalization but remains readable. Reading flow: Class attributes, initialization, and SQL generation appear in a natural sequence. Additional spacing between imports and the class would improve visual separation.

Run 2

Code Structure: The class is logically organized, with attributes followed by initialization and SQL generation; unused imports add clutter. Nesting: The code is flat, with no deeply nested control flow. Clarity of intent: Names and the comment clearly communicate the class's role, though the expected shape of sqls and params is implicit. Code length: The implementation is concise without unnecessary logic, but imports unrelated to this snippet reduce focus. Action granularity: Each statement performs a distinct action; the return expression combines related output preparation appropriately. Reading flow: Execution is easy to follow from storing inputs to wrapping SQL fragments and joining them, with only minor formatting and import distractions.

Run 3

Code Structure: The small class is logically organized, with class-level flags, initialization, and SQL rendering clearly separated. Nesting: The code is flat, with only a simple list comprehension. Clarity of intent: Descriptive method and attribute names, plus the comment, make its purpose clear, although the black-box assumption requires context. Code length: The implementation is concise, but numerous unused imports add clutter to this snippet. Action granularity: Each statement performs a focused action; the return line combines two closely related output transformations without becoming difficult to read. Reading flow: The progression from configuration to stored inputs to SQL output is natural. Additional blank lines around the class and between import groups would improve formatting.