Sample

pyint-f7d3062cfe8f-I05

Rewrite eligible decimal integer literals in hexadecimal notation

Matched original source

Lines32

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8280–1; higher is more readable
Mi0.1820–1; higher is more readable
LLOC20Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.5280–1; higher is more readable

Views

Source code

from django.core.exceptions import FieldError, FullResultSet from django.db.models.expressions import Col from django.db.models.sql.compiler import SQLAggregateCompiler, SQLCompiler from django.db.models.sql.compiler import SQLDeleteCompiler as BaseSQLDeleteCompiler from django.db.models.sql.compiler import SQLInsertCompiler from django.db.models.sql.compiler import SQLUpdateCompiler as BaseSQLUpdateCompiler class SQLDeleteCompiler(BaseSQLDeleteCompiler): def as_sql(self): # Prefer the non-standard DELETE FROM syntax over the SQL generated by # the SQLDeleteCompiler's default implementation when multiple tables # are involved since MySQL/MariaDB will generate a more efficient query # plan than when using a subquery. where, having, qualify = self.query.where.split_having_qualify( must_group_by=self.query.group_by is not None ) if self.single_alias or having or qualify: # DELETE FROM cannot be used when filtering against aggregates or # window functions as it doesn't allow for GROUP BY/HAVING clauses # and the subquery wrapping (necessary to emulate QUALIFY). return super().as_sql() result = ["DELETE %s FROM" % self.quote_name(self.query.get_initial_alias())] from_sql, params = self.get_from_clause() result.extend(from_sql) try: where_sql, where_params = self.compile(where) except FullResultSet: pass else: result.append("WHERE %s" % where_sql) params.extend(where_params) return " ".join(result), tuple(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.1252.248−41.324
Source linesThe number of non-empty source lines.32+12.8
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.732−7.098

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.85+0.567
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.052+0.435
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.33−0.132
Indentation frequencyHow rapidly indentation changes from line to line.25+0.128
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.84.939+0.068
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.31.837+0.035

Intercept 0.07 + feature contributions = 1.569 (log-odds).
Score = sigmoid(1.569) = 0.828.

Score0.182
Score20
Run 1

The code is moderately readable. Structure is logical with a clear single-method class. Nesting is shallow with only one try/except block, and action granularity is mostly one action per line. However, the intent is somewhat obscured by domain-specific Django/MySQL knowledge and a dense explanatory comment. Variable names like 'result' and 'params' are generic, and the mixed string formatting styles (%s and f-strings) slightly disrupt flow. The conditional logic requires understanding of SQL compiler internals, making it less accessible to non-specialists.

Run 2

The code is generally readable with a clear structure and logical flow. It starts with straightforward imports and a single class overriding one method. The method begins with a helpful comment explaining the rationale for the custom SQL generation, which strongly improves clarity of intent. The logic branches only once, avoiding deep nesting, and the path for non-aggregate queries remains flat and easy to follow. Lines are mostly self-contained, though some calls like split_having_qualify and join reduce compactness. The exception handling for FullResultSet is concise but slightly opaque without additional context. One minor issue is the string formatting using the old % operator, which is a bit less natural than modern f-strings but acceptable in legacy Django code. Overall, the method balances conciseness and explicitness well, with clear separation between SQL fragment construction, parameter management, and branch logic.

Run 3

The code is well-structured and readable due to its clear intent, logical organization, and effective use of comments to explain non-obvious behavior. The single method is concise, avoids unnecessary nesting, and maintains a natural reading flow. Action granularity is appropriate—each logical step is separated into distinct lines or blocks. The only minor deductions are for slight complexity in understanding the SQL generation logic and the implicit reliance on superclass behavior, which requires some domain knowledge of Django internals.

Run 1

Code Structure: Imports and a single focused compiler override are logically organized, with SQL assembled in clear stages. Nesting: An early return keeps control flow mostly flat; the try/except/else adds only modest complexity. Clarity of intent: Descriptive names and detailed comments explain both the database-specific optimization and fallback conditions, though Django compiler knowledge is needed to understand the implementation fully. Code length: The method is concise without omitting important context; several imports are unused in the provided snippet. Action granularity: Statements generally perform one action each, making individual steps easy to follow. Reading flow: The sequence naturally progresses from checking eligibility to building, filtering, and returning SQL. The silent FullResultSet exception handling is slightly less explicit, but the overall flow remains readable.

Run 2

Code Structure: A single, focused method organizes SQL generation into clear stages: eligibility checking, FROM construction, WHERE compilation, and final assembly. Nesting: Shallow control flow and an early return keep the main path easy to follow. Clarity of intent: Descriptive identifiers and useful comments explain both the optimization and its limitations, though Django compiler internals and FullResultSet handling require domain knowledge. Code length: Concise implementation with comments proportional to the complexity; several imports are unused in the shown snippet. Action granularity: Each statement performs one clear operation, with no compressed multi-action lines. Reading flow: Execution proceeds naturally from checking constraints to building and returning the query. The try/except/else introduces a small interruption but clearly separates the full-result-set case from WHERE generation.

Run 3

Code Structure: The method is logically organized into condition analysis, fallback selection, SQL construction, and return. Nesting: An early return keeps control flow flat, with only a shallow try/except/else block. Clarity of intent: Descriptive names and useful comments explain both the optimization and its limitations, though Django compiler knowledge is needed to understand some details. Code length: The implementation is concise and avoids redundant logic; the comments are proportionate to the specialized behavior. Action granularity: Each statement performs a distinct operation, and tuple unpacking naturally groups related results. Reading flow: Execution proceeds naturally from eligibility checks through clause assembly to the final SQL and parameters. Minor readability drawbacks include imports unused within the shown snippet and the implicit meaning of passing on FullResultSet.