Sample

pyint-4a3b6c2c9df5-I12

Inline all eligible single-use intermediate local variables

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 Pro150–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 logical structure: it explains the rationale in a comment, checks a condition that falls back to a default implementation, then constructs the custom DELETE SQL step-by-step. Nesting is minimal and action granularity is mostly one action per line. Intent is clarified by the explanatory comment. Minor readability issues include the single-line isinstance-like check combining multiple conditions, and the use of the broad 'except FullResultSet' for control flow, which may obscure normal execution paths. A few long lines (e.g., the fallback condition and the result string join) slightly reduce readability. Overall, the code is understandable for someone familiar with Django's ORM internals, but not immediately accessible to a general audience.

Run 3

The code is fairly readable due to clear comments explaining the non-standard DELETE FROM optimization. The structure is logical, with a single conditional branch and low nesting. Variable names like 'where_sql' and 'where_params' are descriptive. However, readability suffers slightly from the long comment block and the mix of high-level database logic with low-level SQL string building in one method. The 'result' list and tuple conversion add some complexity. The code could be improved by extracting SQL assembly into a helper.

Run 1

Code Structure: Imports and a single compiler override are logically organized, with a clear fallback followed by SQL construction. Nesting: Shallow control flow, an early return, and one try/except/else keep complexity low. Clarity of intent: Descriptive names and useful comments explain both the optimization and its constraints; Django compiler knowledge is still needed to understand some details. Code length: The implementation is concise, though several imports are unused in this snippet. Action granularity: Each statement performs one distinct operation, making query assembly easy to track. Reading flow: Execution progresses naturally from checking eligibility to assembling SQL and returning parameters. The silent FullResultSet handler and framework-specific behavior introduce minor interpretive friction.

Run 2

Code Structure: The compiler subclass and focused as_sql method organize the logic clearly into fallback selection and SQL construction. 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, although Django compiler knowledge is needed to understand some details. Code length: The implementation is concise without obscuring the necessary steps; several imports are unused in the provided snippet. Action granularity: Statements generally perform one action each, and tuple unpacking naturally groups related results. Reading flow: Execution progresses logically from checking eligibility to assembling and returning SQL. Minor drawbacks include the unexplained FullResultSet pass and the lack of the customary second blank line before a top-level class.

Run 3

Code Structure: The compiler subclass organizes SQL generation into clear stages: condition analysis, fallback, clause assembly, and return. Nesting: Shallow control flow and an early return keep the method easy to follow. Clarity of intent: Descriptive names and useful comments explain both the database optimization and its limitations; understanding Django compiler APIs still requires domain knowledge. Code length: The implementation is concise, with comments providing relevant context rather than redundancy. Action granularity: Statements generally perform one action each, and SQL assembly is broken into readable steps. Reading flow: The sequence naturally follows query construction, although the try/except/else handling of FullResultSet and the silent pass require some familiarity with the exception's meaning.