Skip to main content

Module bytecode

Module bytecode 

Source
Expand description

Implement python as a virtual machine with bytecode. This module implements bytecode structure.

Modules§

oparg

Structs§

Arg
Arguments
Argument structure
BasicBag
CodeFlags
CodeObject
Primary container of a single code object. Each python function has a code object. Also a module has a code object.
CodeUnit
CodeUnits
Constants
ExceptionTableEntry
Exception table entry for zero-cost exception handling Format: (start, size, target, depth<<1|lasti)
Label
LoadAttr
LoadSuperAttr
MakeFunctionFlags
OpArg
Full 32-bit op_arg, including any possible ExtendedArg extension.
OpArgByte
Opcode argument that may be extended by a prior ExtendedArg.
OpArgState
StackEffect
What effect the instruction has on the stack.
UnpackExArgs

Enums§

AnyInstruction
BinaryOperator
The possible Binary operators
BorrowedConstant
A borrowed Constant
BuildSliceArgCount
Specifies if a slice is built with either 2 or 3 arguments.
CommonConstant
Common constants for LOAD_COMMON_CONSTANT opcode. pycore_opcode_utils.h CONSTANT_*
ComparisonOperator
COMPARE_OP arg is (cmp_index << 5) | mask. Only the upper 3 bits identify the comparison; the lower 5 bits are an inline cache mask for adaptive specialization.
ConstantData
A Constant (which usually encapsulates data within it)
ConvertValueOparg
Oparg values for Instruction::ConvertValue.
Instruction
A Single bytecode instruction that are executed by the VM.
IntrinsicFunction1
Intrinsic function for CALL_INTRINSIC_1
IntrinsicFunction2
Intrinsic function for CALL_INTRINSIC_2
Invert
Whether or not to invert the operation.
MakeFunctionFlag
SET_FUNCTION_ATTRIBUTE flags. Bitmask: Defaults=0x01, KwOnly=0x02, Annotations=0x04, Closure=0x08, TypeParams=0x10, Annotate=0x20. Stored as bit position (0-5) by bitflag! macro.
PseudoInstruction
Instructions used by the compiler. They are not executed by the VM.
PyCodeLocationInfoKind
CPython 3.11+ linetable location info codes
RaiseKind
The kind of Raise that occurred.
SpecialMethod
Special method for LOAD_SPECIAL opcode (context managers).

Constants§

ADAPTIVE_COOLDOWN_VALUE
Adaptive specialization: cooldown counter after a successful specialization.
ADAPTIVE_WARMUP_VALUE
Adaptive specialization: number of executions before attempting specialization.
CO_FAST_CELL
CO_FAST_FREE
CO_FAST_HIDDEN
Per-slot kind flags for localsplus (co_localspluskinds).
CO_FAST_LOCAL
JUMP_BACKWARD_INITIAL_VALUE
Initial JUMP_BACKWARD counter bits (value/backoff = 4095/12).

Traits§

AsBag
Constant
ConstantBag
A Constant Bag
InstrDisplayContext
InstructionMetadata
OpArgType

Functions§

adaptive_counter_backoff
Reset adaptive counter with exponential backoff.
adaptive_counter_bits
Encode an adaptive counter as (value << 4) | backoff.
adaptive_counter_triggers
True when the adaptive counter should trigger specialization.
advance_adaptive_counter
Decrement adaptive counter by one countdown step.
build_no_location_mask
Parse linetable to build a boolean mask indicating which code units have NO_LOCATION (line == -1). Returns a Vec of length num_units.
decode_exception_table
Decode all exception table entries.
encode_exception_table
Encode exception table entries. Uses 6-bit varint encoding with start marker (MSB) and continuation bit.
find_exception_handler
Find exception handler for given instruction offset.

Type Aliases§

NameIdx