Sample

pyint-895fd648a26e-I10

Deterministically remove some optional blank lines and bracketed line breaks

Matched original source

Lines23

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7610–1; higher is more readable
Mi0.6630–1; higher is more readable
LLOC20Logical lines; fewer is more readable
DeepSeek V4 Pro14.670–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.1790–1; higher is more readable

Views

Source code

from __future__ import annotations import typing as t from base64 import b64decode from base64 import b64encode from datetime import datetime from uuid import UUID from markupsafe import Markup from werkzeug.http import http_date from werkzeug.http import parse_date from ..json import dumps from ..json import loads class TagBytes(JSONTag): __slots__ = () key = " b" def check(self, value: t.Any) -> bool: return isinstance(value, bytes) def to_json(self, value: t.Any) -> t.Any: return b64encode(value).decode("ascii") def to_python(self, value: t.Any) -> t.Any: return b64decode(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.742.8−24.512
Source linesThe number of non-empty source lines.23+9.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.762−7.142

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

Feature contributions

FeatureValueContribution
(log-odds)
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.46.875+1.68
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.24+0.187
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.08+0.165
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.23−0.107
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.22.708−0.092
Indentation frequencyHow rapidly indentation changes from line to line.23+0.058

Intercept 0.07 + feature contributions = 1.156 (log-odds).
Score = sigmoid(1.156) = 0.761.

Score0.663
Score20
Run 1

The code is generally readable but has some issues. The imports are organized logically, and the class uses __slots__ for memory efficiency. However, there is a minor inconsistency in spacing within the key assignment (`key = " b"`), and the methods to_json and to_python are placed on the same visual line, which hurts readability. The methods are concise and do one action each, which is good for action granularity. The intent is fairly clear: serializing bytes to and from base64-encoded ASCII. Nesting is flat, and the code length is reasonable. But the lack of blank lines between methods and the cramped formatting reduce the overall readability. The reading flow is slightly disrupted by the method placement. With minor formatting fixes, this could be much clearer.

Run 2

The code is generally readable with clear imports, a concise class definition, and straightforward methods. Structure is logical, using __slots__ for memory efficiency. Nesting is minimal. Intent is clear: serializing bytes as base64. However, readability is slightly reduced by inconsistent spacing between methods (to_json and to_python lack a blank line separating them) and lack of type annotations on method parameters' return beyond t.Any, which could be more specific. The class body is very short, but the one-line methods after def lines violate action granularity slightly. Overall, the code is clean but could benefit from minor formatting consistency.

Run 3

The code is well-structured and readable overall. It uses clear imports, type hints, and a logical class hierarchy. The class 'TagBytes' has a clear purpose (JSON tag for bytes) with concise methods. However, there are minor readability issues: the methods 'to_json' and 'to_python' are on consecutive lines without a blank line between them, slightly reducing visual separation between methods. Additionally, while the code is concise, it lacks docstrings or comments explaining the encoding/decoding purpose, which would improve clarity of intent. Action granularity is good (one action per line in methods), and the reading flow is natural. Nesting is minimal and structure is flat. The lack of a blank line between methods and missing documentation are the main deductions from an otherwise clean implementation.

Run 1

Code Structure: The class logically groups byte detection and serialization methods, although several imports are unused in this snippet and JSONTag is not defined or imported. Nesting: Minimal nesting makes the code easy to follow. Clarity of intent: Descriptive method names and straightforward Base64 conversions clearly communicate the purpose, but the opaque key " b" and broad Any annotations provide little context. Code length: The implementation is concise, though unused imports add clutter. Action granularity: Each statement occupies its own line, with simple chained operations remaining readable. Reading flow: Methods follow a natural check, encode, decode sequence, but missing blank lines between the imports and class and between conversion methods slightly reduce visual separation.

Run 2

Code Structure: The class logically groups byte detection and conversion methods, although several unused imports and an undefined JSONTag base obscure its standalone context. Nesting: Methods are flat, with no unnecessary branching or nesting. Clarity of intent: TagBytes, check, to_json, and to_python clearly communicate their roles; the opaque key " b" and broad t.Any annotations provide less guidance. Code length: The implementation is concise, but unused imports add clutter. Action granularity: Each statement occupies its own line; the encode-and-decode chain is a cohesive conversion. Reading flow: Methods follow a natural detection, serialization, and deserialization sequence. Missing blank lines between methods and minimal separation around the class slightly weaken visual readability.

Run 3

Code Structure: The class logically groups type checking, serialization, and deserialization, though several imports are unused and JSONTag is not defined or imported in the snippet. Nesting: Methods are flat, with no nested control flow. Clarity of intent: TagBytes and descriptive method names clearly communicate byte conversion using Base64, but the key " b" and __slots__ lack explanatory context. Code length: The implementation is concise, although unused imports add clutter. Action granularity: Each statement performs a focused action; the encode-and-decode chain is compact and understandable. Reading flow: Methods follow a natural check-to-serialization-to-deserialization order, but the missing blank line between to_json and to_python slightly reduces visual separation.