Sample
pyint-a0efaa60fb1f-I13
Lower every eligible synchronous for loop to a while loop
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.673 | 0–1; higher is more readable |
| Mi | 0.513 | 0–1; higher is more readable |
| LLOC | 25 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 16.33 | 0–20; mean of three runs |
| GPT-6.1 Sol | 17.67 | 0–20; mean of three runs |
| BTTF | 0.633 | 0–1; higher is more readable |
Views
Loading feature diagnosis…
Source regions
Feature contributions
Feature contributions
| Feature | Value | Contribution (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. | 1668.406 | −55.057 |
| Source linesThe number of non-empty source lines. | 62 | +24.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.509 | −6.764 |
Intercept 8.87 + feature contributions = -28.151 (log-odds).
Score = sigmoid(-28.151) = 0.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 62 | −1.159 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 53 | +1.096 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 53 | −0.795 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 84.873 | +0.565 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 61.942 | +0.456 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.053 | +0.424 |
| 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.968 | +0.066 |
Intercept 0.07 + feature contributions = 0.723 (log-odds).
Score = sigmoid(0.723) = 0.673.
| Score | 0.513 |
|---|
| Score | 25 |
|---|
Run 1
The code is generally readable with clear imports, logical structure, and good variable naming. The main method is well-organized and focused, using meaningful intermediate variables like `year`, `month`, `day`, and `lookup_kwargs`. Comments explain non-obvious behavior, and action granularity is appropriate. However, the error-raising block contains dense string formatting that interrupts flow, and the `_date_from_string` call breaks from class methods to use a standalone function, which could confuse intent. The mixin inheritance with multiple base classes may require added cognitive load, though this is a common Django pattern. Overall, the code is concise but could benefit from extracting error handling or simplifying formatting logic.
Run 2
The code is highly readable with clear logical structure: imports grouped by source, a focused view class, and a single well-defined method. Nesting is minimal, with only one conditional and no deep indentation. Intent is explicit through descriptive method/variable names and helpful comments explaining non-obvious steps. Code length is concise and avoids unnecessary repetition. Action granularity is mostly one action per line, improving debuggability. Reading flow is natural, progressing from extracting URL date components, to future-date validation, to queryset filtering and delegation to the parent class. Minor deductions: the long format string with placeholders slightly reduces readability, and the conditional queryset assignment could be simplified. Overall, the code follows Django conventions and is easy to follow.
Run 3
The code is highly readable with clear structure and organization. It follows Django conventions, has logical grouping of imports and a well-structured class with a single focused method. The nesting is minimal—only one conditional block—and the reading flow is natural, moving from argument extraction to date parsing, validation, query filtering, and delegation. Variable names like 'year', 'month', 'day', and 'qs' are clear, and comments explain non-obvious steps. The docstring provides useful context about the class purpose. The only minor issues are the slightly long error-raising block with string formatting, and the method could arguably be split into smaller helpers, but overall it is concise and readable.
Run 1
Code Structure: The class and method are logically organized, separating date extraction, queryset selection, validation, filtering, and retrieval. Nesting: Control flow is shallow, with a single conditional and no nested branches. Clarity of intent: Descriptive method names, a useful class docstring, and explanatory comments make the purpose clear; however, qs is abbreviated and several mixins and helpers are not defined in the snippet. Code length: The implementation is reasonably concise, though some comments repeat obvious operations and several imports are unused here. Action granularity: Most statements perform one clear action, and multiline calls improve legibility. Reading flow: Execution follows a natural sequence from URL date parsing to validation and object retrieval, although the verbose exception construction briefly interrupts that flow.
Run 2
Code Structure: The method is logically organized into date extraction, queryset selection, future-date validation, filtering, and object retrieval. Nesting: A single conditional keeps control flow shallow; multiline error formatting adds visual depth without complex branching. Clarity of intent: Descriptive method names, a useful class docstring, and contextual comments make the purpose clear, although 'qs' is abbreviated and several mixins and helpers are not defined in the excerpt. Code length: The implementation is reasonably concise, but unused imports and verbose exception construction add some overhead. Action granularity: Most statements perform one clear action, with multiline expressions formatted consistently. Reading flow: Execution proceeds naturally from request parameters to validation and retrieval, though framework-specific inheritance and helper calls require some Django familiarity.
Run 3
Code Structure: The method follows a logical sequence: extract date components, parse the date, select a queryset, validate future-date access, filter, and delegate retrieval. Nesting: Control flow is shallow, with only one conditional; the multiline exception formatting adds visual depth but little complexity. Clarity of intent: Descriptive method names, a class docstring, and targeted comments explain the purpose well, though undefined mixins/helpers and the abbreviated name 'qs' require some external context. Code length: The implementation is reasonably concise, although several imports are unused in this excerpt and exception formatting occupies substantial space. Action granularity: Each statement generally performs one distinct action, with multiline arguments improving readability. Reading flow: Execution proceeds naturally from inputs to validation to retrieval, with whitespace separating meaningful stages.