Skip to main content

Module value

Module value 

Source

Structs§

ClassValue
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).
CoroutineValue
A suspended async def call (see Value::Coroutine).
DataclassField
A single field of an @dataclass-decorated class.
DefaultDictData
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.
DictBody
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.
ExceptionValue
A runtime exception value that can be raised and caught by user code.
FunctionDef
Stored representation of a user-defined function (def). Captures closure at DEFINITION time.
FunctionParams
Function parameter specification.
InstanceValue
A user-defined class instance: its class name plus its own attributes.
LambdaDef
Stored representation of a lambda.
ListBody
LruCacheData
Shared state for Value::LruCache.
MatchGroup
One capture group of a MatchValue: its text and character span.
MatchValue
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.
Param
A single function parameter.
PartialData
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.
PropertyDef
A @property data descriptor.
SingleDispatchData
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.
SliceValue
A slice(start, stop, step) object’s bounds.
StringIoData
Backing state for Value::StringIO — the text buffer and the read/write cursor. write overwrites from pos (extending as needed); read/ readline advance pos.

Enums§

BoundMethodReceiver
The receiver of a Value::BoundMethod.
BoundMethodStep
One accessor in a BoundMethodReceiver::Place chain.
BuiltinIterName
The dynamic value type flowing through the interpreter.
DecimalKind
The sign/special-value tag on a Value::Decimal — what bigdecimal cannot itself represent.
DictViewKind
Which live dict view a Value::DictView is.
EnumKind
Enum kind drives EnumMember equality + arithmetic semantics.
LazyKind
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.
OperatorGetter
Backing data for Value::OperatorGetter — the three callable factories in the operator module. Each applies to a single argument at call time.
Value
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.
ValueKey
Dict keys must be hashable — a subset of Value.

Functions§

char_is_printable
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.
int_from_bigint
Build a Python int value, using Value::Int when it fits in i64.
is_builtin_type_name
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_str_repr
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).
shared_bytes
Construct a fresh SharedByteArray from a Vec<u8>.
shared_dict
Construct a fresh SharedDict from an IndexMap.
shared_fields
Construct a fresh SharedFields map.
shared_list
Construct a fresh SharedList from a Vec<Value>. Centralised so call sites use this instead of inlining Arc::new(Mutex::new(v)).
shared_set
Construct a fresh SharedSet from a set body.
shared_stringio
Construct a fresh SharedStringIo seeded with initial text.
value_as_bigint
Lift a Python numeric value to BigInt (int / bigint / bool).
value_as_i64
Narrow to i64 when the value is a small int (or bool).

Type Aliases§

SharedByteArray
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.
SharedDict
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.
SharedFields
Shared instance-field map backing InstanceValue::fields.
SharedFrozenset
Shared backing store for Value::Frozenset. Immutable, so no Mutex; cloning is an Arc refcount bump and is-identity compares the pointer.
SharedList
Shared, interior-mutable list storage backing Value::List.
SharedSet
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).
SharedStringIo
Shared, reference-semantic io.StringIO state (an alias shares the buffer, like bytearray/list).