Sample
pyint-232e3838bfa8-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.193 | 0–1; higher is more readable |
| Mi | 0.561 | 0–1; higher is more readable |
| LLOC | 104 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 10 | 0–20; mean of three runs |
| GPT-6.1 Sol | 13 | 0–20; mean of three runs |
| BTTF | 0.282 | 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. | 7213.299 | −238.039 |
| Source linesThe number of non-empty source lines. | 224 | +89.6 |
| 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.255 | −6.383 |
Intercept 8.87 + feature contributions = -145.952 (log-odds).
Score = sigmoid(-145.952) = 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. | 225 | −6.93 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 207 | +6.423 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 207 | −4.329 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 223.918 | +2.72 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 94.747 | +0.724 |
| 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. | 95.956 | −0.399 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.067 | +0.292 |
Intercept 0.07 + feature contributions = -1.429 (log-odds).
Score = sigmoid(-1.429) = 0.193.
| Score | 0.561 |
|---|
| Score | 104 |
|---|
Run 1
The code has good type hints, docstrings, and logical structure, but suffers from poor readability due to deep nesting and convoluted iteration patterns. The `_encode_params` method uses manual while loops with `__import__('builtins')` instead of standard Python constructs, which obscures intent and adds unnecessary complexity. The nested loops for processing key-value pairs and files create multiple levels of indentation, making the flow harder to follow. While the code is functionally organized, the manual iteration and explicit exception handling for `StopIteration` are unidiomatic and reduce clarity. The `_encode_files` method is clearer but still has non-obvious variable names (`fn`, `fp`, `ft`, `fh`) and inline conditional logic that hampers readability. Overall, the code demonstrates good structural organization and typing, but the implementation choices significantly impair readability and maintainability.
Run 2
The code has clear type hints and docstrings, but readability is severely compromised by several factors: (1) the `_encode_params` method uses convoluted `__import__('builtins').next()` calls instead of Python's normal `for` loops or `next()` builtin, making it unnecessarily obscure; (2) deep nesting in `_encode_files` (up to 4 levels) with multiple conditional branches obscures flow; (3) multiple actions are packed into single lines, violating one-action-per-line granularity; (4) `_encode_files` mixes tuple unpacking, type checks, and object construction in tight blocks, making it hard to follow; (5) excessive type checking (`isinstance`, `hasattr`) creates repetitive, noisy logic; (6) the `while True` with explicit `StopIteration` catching is a low-level pattern that breaks natural reading flow. While imports are organized and classes/methods are logically grouped, the core logic is tangled and requires significant mental effort to parse.
Run 3
The code has clear structure and good documentation but suffers from readability issues in specific areas. The class organization is logical, and type hints are comprehensive. However, the _encode_params method uses awkward manual iteration with __import__('builtins') instead of standard Python constructs, which significantly harms clarity. The nested while loops with try-except for StopIteration create unnecessary depth and obscure intent. Action granularity is inconsistent - some lines pack multiple operations while others are over-verbose. The _encode_files method is more readable with clearer flow but still has moderately deep nesting. The extensive imports and type annotations add visual noise but serve documentation purposes. Overall, the code demonstrates professional quality with good docstrings and error handling, but the non-idiomatic iteration pattern and inconsistent nesting prevent it from being highly readable.
Run 1
Code Structure: Methods logically separate URL construction, parameter encoding, and multipart encoding, with helpful docstrings and type annotations. Nesting: Encoding methods contain several nested loops and conditionals; explicit iterator loops with try/except add avoidable depth. Clarity of intent: Method names and documentation explain purposes, but abbreviated variables such as k, vs, ft, and fh obscure details. Repeated dynamic imports of builtins make ordinary iteration unnecessarily difficult to interpret. Code length: The large import block, overload declarations, and expanded iterator handling increase reading overhead; standard for loops would substantially simplify _encode_params. Action granularity: Statements generally perform one action per line, although conditional expressions inside tuple construction require extra parsing. Reading flow: Formatting and method boundaries support sequential reading, but exception-driven iteration interrupts the flow, and multipart handling requires tracking several short-named variables across branches. Overall, the organization is sound, but localized verbosity and complexity noticeably reduce readability.
Run 2
Code Structure: Imports, a focused mixin, and separate encoding methods provide logical organization. Nesting: Multipart processing has moderate nesting, while parameter encoding adds unnecessary nested while/try/except blocks. Clarity of intent: Method names, docstrings, and type annotations explain the purpose, but abbreviated variables and repeated dynamic builtins imports obscure straightforward iteration. Code length: Extensive imports and overloads add visual overhead; manually implementing iterator advancement makes _encode_params substantially longer than necessary. Action granularity: Most lines perform one action, with tuple unpacking and conditional expressions remaining reasonably readable. Reading flow: Formatting and method boundaries support navigation, but artificial loop machinery interrupts natural flow and distracts from the encoding logic. Overall, the code is understandable, yet avoidable iteration complexity noticeably reduces readability.
Run 3
Code Structure: Imports, a focused mixin, and separate encoding methods provide logical organization. Nesting: Multipart encoding has moderate nesting, while parameter encoding becomes unnecessarily deep through nested while loops and try/except blocks. Clarity of intent: Method names, docstrings, and type annotations explain the purpose, but abbreviated variables and generic iterator names obscure details. Code length: Extensive imports and overloads add overhead; manually implementing iteration with repeated __import__("builtins") calls is substantially more verbose than ordinary for loops. Action granularity: Most statements perform one action per line, although conditional expressions inside tuple construction require extra parsing. Reading flow: Validation, normalization, and encoding generally follow a natural sequence, but the unusual iterator machinery interrupts that flow and distracts from otherwise straightforward logic.