Sample

pyint-e7bed578aca9-I05

Rewrite eligible decimal integer literals in hexadecimal notation

Matched original source

Lines24

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7590–1; higher is more readable
Mi0.6820–1; higher is more readable
LLOC20Logical lines; fewer is more readable
DeepSeek V4 Pro17.330–20; mean of three runs
GPT-6.1 Sol180–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.24+9.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.762−7.142

Intercept 8.87 + feature contributions = -13.185 (log-odds).
Score = sigmoid(-13.185) = 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.92+1.678
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.08+0.165
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.25+0.151
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.24−0.13
Indentation frequencyHow rapidly indentation changes from line to line.24+0.093
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.23.708−0.078

Intercept 0.07 + feature contributions = 1.145 (log-odds).
Score = sigmoid(1.145) = 0.759.

Score0.682
Score20
Run 1

The code is clean and readable. It follows a logical structure with clear imports and a focused class definition. Nesting is minimal and intent is unambiguous for each method. The use of type hints, __slots__, and a class-level key attribute demonstrates good design and reduces ambiguity. Each method performs a single action, and the flow is natural (check → serialize → deserialize). Although it omits the parent class definition, the code is concise and easy to follow.

Run 2

The code demonstrates high readability through clean organization, flat structure, and focused methods. Each method has a single responsibility (validation, serialization, deserialization), with clear return type hints and concise logic. The class structure follows a consistent pattern typical of serialization tag systems, making intent immediately clear to domain-aware readers. Nesting is nonexistent, and action granularity is ideal — one operation per line in each method. Imports are well-organized and the use of `__slots__` shows intent to optimize memory. A minor deduction: the class references `JSONTag` which is not imported in the visible snippet, potentially causing confusion about the inheritance source. Additionally, the `key = " b"` value with a space is unusual and might benefit from a comment explaining its purpose. Overall, the code follows clean, idiomatic Python conventions with excellent readability.

Run 3

The code is highly readable with a clear, logical structure. It follows a flat hierarchy with no nested blocks, making the flow easy to follow. Each class method performs a single, well-defined action, contributing to strong action granularity. Imports are organized, though some could be consolidated (e.g., from base64 import b64decode, b64encode). The class and method names clearly express intent. The code is concise, with no unnecessary verbosity. The lack of docstrings or type hints for return values (beyond t.Any) is a minor weakness, but the use of __slots__ and the straightforward transformations keep the purpose unambiguous. Overall, it reads naturally and would be easily understood by a developer familiar with JSON serialization patterns.

Run 1

Code Structure: The class logically groups byte detection, JSON encoding, and Python decoding, although several imports are unused and JSONTag is not defined or imported in the excerpt. Nesting: Methods are flat with no unnecessary nesting. Clarity of intent: Class and method names clearly convey a bytes serialization adapter; the opaque key " b" lacks explanation. Code length: Methods are concise, but unused imports add clutter. Action granularity: Each statement performs one clear action; chaining encoding and decoding is straightforward. Reading flow: The progression from checking to encoding to decoding is natural, though import grouping and spacing before the class could improve presentation.

Run 2

Code Structure: The class logically groups byte detection, JSON conversion, and Python conversion into separate methods. Nesting: There is no nested control flow, making the code easy to scan. Clarity of intent: Descriptive method names and straightforward Base64 operations clearly communicate the serialization purpose, although JSONTag is not defined or imported in the snippet and the key " b" is unexplained. Code length: The implementation is concise, but several imports are unused in the shown code and add clutter. Action granularity: Each statement performs one clear action; the encode-and-decode chain remains simple and readable. Reading flow: The methods follow a natural check-to-serialization-to-deserialization sequence. Additional spacing between imports and the class would improve visual organization.

Run 3

Code Structure: The class logically groups byte-type checking and serialization/deserialization into separate methods. Nesting: The code is flat, with no nested conditionals or loops. Clarity of intent: Method names and standard Base64 operations clearly convey the conversion purpose, although the opaque key " b" and unexplained JSONTag base class require external context. Code length: The implementation is concise, but several unused imports add clutter. Action granularity: Each method contains one straightforward return statement; the chained encode/decode expression remains easy to understand. Reading flow: The progression from checking a value to encoding and decoding it is natural. Additional spacing between imports and the class would improve visual separation.