The definition of a user-defined class, held in the interpreter’s class
registry (not as a Value — variables hold a lightweight Value::Class
handle that names this entry).
Backing data for Value::DefaultDict — the entries + the missing-key
factory. Stored behind a Box on the DefaultDict variant so the
inline Value enum slot stays narrow.
The entries of a dict, plus a lazily-computed byte-size cache. Same design
and rationale as ListBody — see its docs for the cache/invalidation
contract and why it is not Clone.
A regex match: its capture groups (index 0 is the whole match) plus a
name→index map for named groups. Offsets are character indices, matching
Python’s str-based re.
Backing data for Value::Partial — the bound callable + its
captured positional / keyword args. Stored behind a Box on the
Partial variant so the inline Value enum slot stays narrow.
Shared state for Value::SingleDispatch — a
functools.singledispatch generic function. The default
implementation handles argument types with no registered override;
registry maps a type name to its implementation, in registration
order. Shared behind an Arc so the .register decorator (which
clones the wrapper value) mutates the same table the caller dispatches
against, matching CPython’s single generic-function object.
Backing state for Value::StringIO — the text buffer and the read/write
cursor. write overwrites from pos (extending as needed); read/
readline advance pos.
What a Value::Lazy cursor was produced by, carried inline so
type(x).__name__/repr reflect CPython’s distinct iterator types
(map, filter, chain, …) without a state lookup. Generator is
the default — a genuine generator expression or a def/method generator
eagerly buffered into a cursor, both of which CPython names generator.
Every variable, tool argument, and return value is a Value. This enum
covers all Python types the interpreter supports. Use the as_*() methods
for borrowing access, try_into_*() for consuming access, or pattern matching.
CPython str.isprintable() for a single char: printable unless its Unicode
general category is Other (Cc/Cf/Cs/Co/Cn) or Separator (Zl/Zp/Zs). ASCII
space (U+0020) is the sole exception — printable despite being a Zs
separator. Drives both str.isprintable() and repr escaping so they agree.
Whether a bare builtin name refers to a type (which reprs as
<class 'name'>) rather than a plain builtin function (<built-in function name>). Covers the scalar/container types plus the builtin
iterator/wrapper types that CPython also exposes as classes.
Python repr() of a string: CPython’s quote selection plus escaping.
Single quotes are preferred, switching to double only when the string
contains a single quote but no double quote. Backslash, the active quote,
and the C0/DEL control characters are escaped; printable Unicode is kept
verbatim (matching str.isprintable() for the common ranges).
Mutable, shared backing store for Value::ByteArray. Same identity model
as SharedList: a bytearray clone shares storage, so in-place mutation
(b[0] = ..., .append(...)) is visible through every alias.
Shared backing store for Value::Dict. Same identity model as
SharedList: cloning a dict Value is a refcount bump, so key
writes / del / .update through any alias are visible on every
other alias and through a dict passed to a function — matching
CPython’s dict reference semantics.
Mutable, shared backing store for Value::Set. Same identity model as
SharedList: a set clone shares storage, so .add/.discard through
any alias (or a function argument) are visible everywhere — matching
CPython’s set reference semantics. The body carries CPython’s hash-table so
iteration order matches CPython (see the pyset module).