Sample

pyint-71d67d383df4-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines35

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7270–1; higher is more readable
Mi0.1930–1; higher is more readable
LLOC23Logical lines; fewer is more readable
DeepSeek V4 Pro13.330–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.4120–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. running_total = 0 for current_number in range(1, 6): running_total += current_number 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.1389.074−45.839
Source linesThe number of non-empty source lines.35+14
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.719−7.078

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.84.944+0.566
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.053+0.428
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.36−0.238
Indentation frequencyHow rapidly indentation changes from line to line.28+0.231
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.28−0.222
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.34.837+0.077
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.944+0.067

Intercept 0.07 + feature contributions = 0.98 (log-odds).
Score = sigmoid(0.98) = 0.727.

Score0.193
Score23
Run 1

The code has clear intent and some good comments explaining the MySQL/MariaDB DELETE FROM optimization, but suffers from several readability issues. The unused loop with 'running_total' is confusing dead code that breaks action granularity and reading flow. The method is moderately long and handles multiple conditions, but nesting is mostly flat. The try/except/else structure adds slight complexity. Variable naming is generally good, and the SQL construction follows a logical order. The comment explaining why super().as_sql() is called for aggregates/window functions is helpful. Overall, the code is functional and partially readable but the dead loop, mixed concerns in one method, and slightly awkward control flow prevent a higher score.

Run 2

The code is generally readable with clear intent and logical structure. It demonstrates good organization with imports separated from the class definition, a class name that clearly indicates its purpose, and a method with a descriptive name. The code includes helpful comments explaining the MySQL/MariaDB optimization and why certain paths fall back to default behavior. Nesting is minimal with only one if-else and try-except structure. However, there is a significant issue: a meaningless loop calculating 'running_total' that appears unrelated to the method's purpose, which introduces confusion and unnecessary code. The method also performs multiple actions (splitting queries, checking conditions, building SQL strings, compiling where clauses) without clear separation, though this is somewhat inherent to SQL compilation. Variable names like 'where_sql' and 'where_params' are clear, and the reading flow is natural despite the complexity of the domain. The unnecessary loop prevents a higher score.

Run 3

The code is moderately readable but has notable issues. The structure is logical and imports are organized, but unnecessary code (the pointless loop) damages clarity of intent and code length. Nesting is acceptable with only one try-except and conditionals. Reading flow is mostly natural, but the loop breaks it. Action granularity is good - one action per line. The variable 'running_total' has no purpose in the DELETE SQL generation logic. The try/except with 'pass' and 'else' clause is somewhat unusual but understandable. Comments explain the intent well despite the confusing loop. Overall, the core SQL logic is clear, but the unnecessary code and confusing placement reduce readability significantly.

Run 1

Code Structure: Imports and a single focused method are logically organized, but the unused running_total loop is unrelated clutter. Nesting: Shallow control flow, an early return, and a straightforward try/except/else keep complexity manageable. Clarity of intent: Descriptive names and useful comments explain the SQL optimization and fallback conditions; the unexplained summation loop undermines that clarity. Code length: Mostly concise, with three unnecessary lines devoted to the unused calculation. Action granularity: Statements generally perform one action per line, making SQL assembly easy to follow. Reading flow: The progression from eligibility checks to clause construction and return is natural, though the irrelevant loop interrupts it and framework-specific APIs require Django knowledge.

Run 2

Code Structure: The method logically separates fallback selection, DELETE construction, and WHERE compilation, but unused imports and an unrelated running_total loop introduce clutter. Nesting: Shallow loops and conditionals keep complexity low; the try/except/else is manageable. Clarity of intent: Descriptive compiler APIs and comments explain the SQL optimization and fallback restrictions, although the unused calculation distracts from that purpose. Code length: The implementation is reasonably concise, but removing the irrelevant loop and unused imports would improve it. Action granularity: Statements generally perform one action per line, with conventional tuple unpacking for related results. Reading flow: SQL construction follows a natural progression from DELETE to FROM to WHERE, but the unexplained arithmetic interrupts that flow. Overall, readable domain-specific code with noticeable extraneous material.

Run 3

Code Structure: The compiler override is logically organized around fallback handling and SQL assembly, but the unused running_total loop and several unused imports introduce unrelated clutter. Nesting: Shallow nesting and an early return keep control flow easy to follow. Clarity of intent: Descriptive framework method names and informative comments explain the specialized DELETE syntax and its limitations; the arithmetic loop has no apparent purpose. Code length: The implementation is reasonably concise, although removing the loop and unused imports would improve focus. Action granularity: Statements generally perform one action per line, with clear separation between clause generation, compilation, and parameter updates. Reading flow: The sequence from eligibility checks to query construction and return is natural, but the irrelevant loop interrupts it, and understanding the exception handling requires familiarity with Django's compiler conventions.