Sample

pyint-ccf455e964fe-I13

Lower every eligible synchronous for loop to a while loop

Matched original source

Lines43

Scores

MethodScoreScale
Posnett0.020–1; higher is more readable
Dorn0.8580–1; higher is more readable
Mi0.5840–1; higher is more readable
LLOC22Logical lines; fewer is more readable
DeepSeek V4 Pro17.330–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.7470–1; higher is more readable

Views

Source code

from __future__ import annotations import collections.abc as c import hashlib import typing as t from collections.abc import MutableMapping from datetime import datetime from datetime import timezone from itsdangerous import BadSignature from itsdangerous import URLSafeTimedSerializer from werkzeug.datastructures import CallbackDict from .json.tag import TaggedJSONSerializer class SessionMixin(MutableMapping[str, t.Any]): """Expands a basic dictionary with session attributes.""" @property def permanent(self) -> bool: """This reflects the ``'_permanent'`` key in the dict.""" return self.get("_permanent", False) # type: ignore[no-any-return] @permanent.setter def permanent(self, value: bool) -> None: self["_permanent"] = bool(value) #: Some implementations can detect whether a session is newly #: created, but that is not guaranteed. Use with caution. The mixin # default is hard-coded ``False``. new = False #: Some implementations can detect changes to the session and set #: this when that happens. The mixin default is hard coded to #: ``True``. modified = True accessed = False """Indicates if the session was accessed, even if it was not modified. This is set when the session object is accessed through the request context, including the global :data:`.session` proxy. A ``Vary: cookie`` header will be added if this is ``True``. .. versionchanged:: 3.1.3 This is tracked by the request context. """

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.696.883−22.997
Source linesThe number of non-empty source lines.43+17.2
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.653−6.979

Intercept 8.87 + feature contributions = -3.906 (log-odds).
Score = sigmoid(-3.906) = 0.02.

Feature contributions

FeatureValueContribution
(log-odds)
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.026+0.69
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.44−0.522
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.73.795+0.386
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.78.909+0.323
Indentation frequencyHow rapidly indentation changes from line to line.29+0.266
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.42.875+0.189

Intercept 0.07 + feature contributions = 1.801 (log-odds).
Score = sigmoid(1.801) = 0.858.

Score0.584
Score22
Run 1

The code is well-structured with clear class definition and logical grouping of properties and attributes. Nesting is minimal—only one class and no deep indentation. The intent is clear: extending a dictionary with session-specific behavior. Code length is concise; each property is short and focused. Action granularity is appropriate, with one logical action per line. Reading flow is natural, moving from imports to class definition to documented attributes. Type hints and docstrings improve understandability. Minor deductions include a couple of slightly long lines and mixed import styles, but overall readability is strong.

Run 2

The code is highly readable with clear structure and intent. Class definition and inheritance are explicit, and the property setter/getter for 'permanent' is cleanly implemented with docstrings explaining behavior. Import statements are logically organized, though some unused imports (hashlib, datetime, timezone, BadSignature, URLSafeTimedSerializer, CallbackDict, TaggedJSONSerializer) slightly reduce clarity. The class attributes 'new', 'modified', and 'accessed' are documented via comments and docstrings, aiding comprehension. Nesting is minimal. One minor improvement could be removing unused imports to reduce cognitive load. Overall, the code follows good Python practices and maintains a natural reading flow.

Run 3

The code is well-structured with clear separation of concerns: a single SessionMixin class extending MutableMapping with documented attributes. Nesting is flat and action granularity is appropriate - each line performs one logical operation. Clarity of intent is excellent, with descriptive property names (permanent, new, modified, accessed) and comprehensive docstrings explaining behavior. The property setter correctly coerces values to bool, and the getter uses a sensible default. Imports are organized and typed properly with from __future__ import annotations. The code length is concise yet complete for the functionality provided. Reading flow is natural, progressing from imports to class definition to properties and attributes. Minor deductions: a type ignore comment and slightly verbose docstrings for simple attributes, but these don't significantly impact readability. Some imports (hashlib, datetime, itsdangerous) appear unused in this snippet, which could cause minor confusion.

Run 1

Code Structure: Imports and session attributes are logically organized within a focused mixin, though import grouping could be clearer. Nesting: Methods are flat, with no complex control flow. Clarity of intent: Descriptive names, type annotations, and documentation clearly explain session behavior; abbreviated import aliases and the type-ignore comment add minor friction. Code length: The implementation is concise, although documentation occupies most of the snippet and some imports are unused here. Action granularity: Each executable line performs one clear action. Reading flow: The getter and setter appear together, followed by related flags, creating a natural progression. Mixed documentation styles—preceding comments versus a trailing attribute docstring—slightly interrupt consistency.

Run 2

Code Structure: Imports and a single focused mixin are logically organized, though import grouping could be clearer. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: Descriptive session attributes, type annotations, and documentation clearly explain behavior; abbreviated import aliases are slightly less explicit. Code length: The implementation is concise, with documentation longer than the executable code but generally useful. Action granularity: Each executable line performs one clear action. Reading flow: The property getter and setter appear together, followed by session-state defaults in a natural sequence. Mixed documentation styles and uneven comment detail slightly disrupt consistency.

Run 3

Code Structure: Imports and a focused mixin class provide logical organization, though several imports are unused in this snippet. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: Descriptive attribute names, type annotations, and documentation clearly explain session behavior; abbreviated import aliases are slightly less intuitive. Code length: The implementation is concise, although documentation is lengthy relative to the executable code. Action granularity: Each statement performs one clear action, with no compressed multi-action lines. Reading flow: The getter, setter, and session flags follow a natural progression. Mixed documentation styles and limited separation between imports and the class slightly interrupt visual consistency.