Sample

pyint-a436934eb229-I01

Remove comments and docstrings

Matched original source

Lines46

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.5520–1; higher is more readable
Mi0.7530–1; higher is more readable
LLOC26Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.5780–1; higher is more readable

Views

Source code

from __future__ import annotations import abc import contextlib import enum import itertools import linecache import sys import types import unicodedata import weakref from collections.abc import Callable, Mapping from functools import cached_property from typing import Any, NamedTuple, TypeVar from . import _compat, _config, setters from ._compat import ( PY_3_11_PLUS, PY_3_13_PLUS, _AnnotationExtractor, _get_annotations, _lazy_is_generator, get_generic_base, ) from .exceptions import ( DefaultAlreadySetError, FrozenInstanceError, NotAnAttrsClassError, UnannotatedAttributeError, ) class Factory: __slots__ = ("factory", "takes_self") def __init__(self, factory, takes_self=False): self.factory = factory self.takes_self = takes_self def __getstate__(self): return tuple(getattr(self, name) for name in self.__slots__) def __setstate__(self, state): for name, value in zip(self.__slots__, state, strict=True): setattr(self, name, value)

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.1031.235−34.031
Source linesThe number of non-empty source lines.46+18.4
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.562−6.843

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.46+0.854
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
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.67.936+0.788
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.46−0.635
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.47−0.628
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.063+0.333
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.45.812+0.231

Intercept 0.07 + feature contributions = 0.209 (log-odds).
Score = sigmoid(0.209) = 0.552.

Score0.753
Score26
Run 1

The code demonstrates strong readability through logical structure, with clear separation of imports (std lib, third-party, local) and a well-organized class definition. Nesting is minimal and flat, containing only straightforward __init__, __getstate__, and __setstate__ methods. Intent is clear - Factory is a simple container class for lazy attribute initialization. The code is concise without unnecessary verbosity, using __slots__ appropriately. Action granularity shows one action per line in most cases, though the zip() and setattr() in __setstate__ might be slightly more complex for some readers. Reading flow is natural, following standard Python conventions. Minor deductions for: redundant empty comment lines that could be docstrings, and lack of type hints which could enhance clarity. The strict=True parameter in zip() assumes Python 3.10+, which may not be immediately obvious to all users. Overall, this is highly readable code with only minor improvements possible.

Run 2

The code is generally readable with a clear, logical structure. Imports are organized and follow standard conventions, with clear grouping of standard library, third-party, and local modules. The Factory class is concise with a simple purpose and uses __slots__ appropriately. However, the score is limited by several factors: the class begins with an unnecessary blank line after declaration, the __init__ parameters lack type hints despite the file using modern typing features, the __getstate__ and __setstate__ methods have no docstrings explaining why custom serialization is needed, and the zip call with strict=True assumes equal-length sequences without documenting that invariant. The code reads naturally overall, but these minor readability gaps prevent a higher score.

Run 3

The code demonstrates good structure with clear imports and a focused class definition. The Factory class is concise with explicit __slots__ and a straightforward constructor. However, readability suffers from several issues: undocumented empty lines after class/method definitions suggest stripped docstrings, reducing clarity of intent. The use of __getstate__ and __setstate__ without docstrings explaining serialization behavior adds ambiguity. The zip with strict=True is obscure without context. While the class itself is flat and actions are granular, the overall readability is compromised by the missing documentation that would explain the 'why' behind the Factory design, the takes_self parameter semantics, and custom serialization logic. The code is syntactically clear but semantically opaque, suggesting domain knowledge is required to fully understand its purpose and behavior.

Run 1

Code Structure: Imports are grouped sensibly, and the Factory class cleanly separates initialization and state serialization. Nesting: Minimal nesting makes the methods easy to follow. Clarity of intent: Names such as factory, takes_self, __getstate__, and __setstate__ convey their roles, though takes_self lacks explanatory context. Code length: The class is concise, but numerous imports unused in the displayed snippet and redundant blank lines add clutter. Action granularity: Statements generally perform one action per line; the tuple comprehension is compact and readable. Reading flow: Methods appear in a natural order, with serialization followed by restoration, although the long import section delays reaching the small class.

Run 2

Code Structure: Imports and the Factory class are logically organized, although many imports are unused in this snippet. Nesting: Methods are flat, with only a simple loop in __setstate__. Clarity of intent: Names such as factory and takes_self are understandable, and the state methods use standard Python conventions, but missing documentation leaves their contract implicit. Code length: The class is concise, while the extensive import block and extra blank lines add visual clutter. Action granularity: Each statement performs a focused action; the generator expression is compact without being difficult to follow. Reading flow: Initialization, state extraction, and state restoration appear in a natural order, though the disproportionate import block delays reaching the relevant code.

Run 3

Code Structure: The Factory class is logically organized, with initialization followed by serialization methods, though the many unrelated imports distract from this small excerpt. Nesting: Minimal nesting makes the code easy to follow. Clarity of intent: Descriptive field names and standard method names communicate purpose, but absent documentation and parameter type hints leave factory behavior and takes_self semantics unclear. Code length: The class is concise, although excessive blank lines and apparently unused imports add visual clutter. Action granularity: Statements generally perform one action each; the generator expression is compact and readable. Reading flow: Methods progress naturally, and the state restoration loop clearly mirrors state extraction.