Versions in this module Expand all Collapse all v0 v0.3.0 Feb 21, 2026 Changes in this version type Block + ExcStackLevel int type CodeObject + func (co *CodeObject) CellOrFreeName(idx int) string type Frame + OrderedGlobalKeys []string type Opcode + const OpCallEx + const OpContinueLoop + const OpDeleteDeref + const OpPopBlock + const OpPopExceptHandler type PyException + SuppressContext bool type PyFunction + Dict map[string]Value + KwDefaults map[string]Value type PyGenerator + SavedCurrentException *PyException + SavedExcHandlerStack []*PyException + SavedHasPendingJump bool + SavedHasPendingReturn bool + SavedLastException *PyException + SavedPendingJump int + SavedPendingReturn Value type PyIterator + Source *PyList type VM + func (vm *VM) AllocatedBytes() int64 + func (vm *VM) DefaultClassCall(cls *PyClass, args []Value, kwargs map[string]Value) (Value, error) + func (vm *VM) MaxCollectionSize() int64 + func (vm *VM) MaxMemoryBytes() int64 + func (vm *VM) MaxRecursionDepth() int64 + func (vm *VM) SetMaxCollectionSize(n int64) + func (vm *VM) SetMaxMemoryBytes(n int64) + func (vm *VM) SetMaxRecursionDepth(n int64) + func (vm *VM) TrackAlloc(n int64) error v0.2.0 Feb 19, 2026 Changes in this version type PyBuiltinFunc + Bound bool v0.1.0 Feb 18, 2026 Changes in this version + var CompileFunc func(source, filename, mode string) (*CodeObject, error) + var False = &PyBool + var None = &PyNone + var NotImplemented = &PyNotImplementedType + var OpcodeNames = map[Opcode]string + var True = &PyBool + func BuiltinCompile(vm *VM) int + func BuiltinDir(vm *VM) int + func BuiltinEval(vm *VM) int + func BuiltinExec(vm *VM) int + func BuiltinGlobals(vm *VM) int + func BuiltinLocals(vm *VM) int + func BuiltinRepr(vm *VM) int + func BuiltinVars(vm *VM) int + func GetPendingBuiltins() map[string]GoFunction + func IsBool(v Value) bool + func IsCallable(v Value) bool + func IsDict(v Value) bool + func IsFloat(v Value) bool + func IsInt(v Value) bool + func IsList(v Value) bool + func IsNone(v Value) bool + func IsString(v Value) bool + func IsTrue(v Value) bool + func IsTuple(v Value) bool + func IsUserData(v Value) bool + func RegisterModule(name string, loader ModuleLoader) + func RegisterPendingBuiltin(name string, fn GoFunction) + func RegisterTypeMetatable(typeName string, mt *TypeMetatable) + func ResetModules() + func ResetPendingBuiltins() + func ResetTypeMetatables() + func ResolveRelativeImport(name string, level int, packageName string) (string, error) + func ToGoValue(v Value) any + type Block struct + Handler int + Level int + Type BlockType + type BlockType int + const BlockExcept + const BlockExceptStar + const BlockFinally + const BlockLoop + const BlockWith + type CancelledError struct + func (e *CancelledError) Error() string + type CodeFlags int + const FlagAsyncGenerator + const FlagCoroutine + const FlagGenerator + const FlagIterableCoroutine + const FlagNested + const FlagNewLocals + const FlagNoFree + const FlagOptimized + const FlagVarArgs + const FlagVarKeywords + type CodeObject struct + ArgCount int + CellVars []string + Code []byte + Constants []any + Filename string + FirstLine int + Flags CodeFlags + FreeVars []string + KwOnlyArgCount int + LineNoTab []LineEntry + Name string + Names []string + StackSize int + VarNames []string + func (co *CodeObject) Disassemble() string + func (co *CodeObject) LineForOffset(offset int) int + type ExceptStarState struct + IsBase bool + Message string + Remaining []*PyException + type Frame struct + BlockStack []Block + Builtins map[string]Value + Cells []*PyCell + Code *CodeObject + EnclosingGlobals map[string]Value + Globals map[string]Value + IP int + Locals []Value + SP int + Stack []Value + type GeneratorState int + const GenClosed + const GenCreated + const GenRunning + const GenSuspended + type GenericAlias struct + Args []Value + Origin Value + func (g *GenericAlias) String() string + func (g *GenericAlias) Type() string + type GoFunction func(vm *VM) int + type Instruction struct + Arg int + Line int + Offset int + Op Opcode + type LineEntry struct + EndOffset int + Line int + StartOffset int + type ModuleBuilder struct + func NewModuleBuilder(name string) *ModuleBuilder + func (b *ModuleBuilder) Build() *PyModule + func (b *ModuleBuilder) Const(name string, value Value) *ModuleBuilder + func (b *ModuleBuilder) Doc(doc string) *ModuleBuilder + func (b *ModuleBuilder) Func(name string, fn GoFunction) *ModuleBuilder + func (b *ModuleBuilder) Method(name string, fn GoFunction) *ModuleBuilder + func (b *ModuleBuilder) Register() *PyModule + func (b *ModuleBuilder) SubModule(name string, submodule *PyModule) *ModuleBuilder + func (b *ModuleBuilder) Type(typeName string, constructor GoFunction, methods map[string]GoFunction) *ModuleBuilder + type ModuleLoader func(vm *VM) *PyModule + type Opcode byte + const OpAccumulateFast + const OpAddConstFast + const OpAssert + const OpBinaryAdd + const OpBinaryAddFloat + const OpBinaryAddInt + const OpBinaryAnd + const OpBinaryDivide + const OpBinaryDivideFloat + const OpBinaryFloorDiv + const OpBinaryLShift + const OpBinaryMatMul + const OpBinaryModulo + const OpBinaryMultiply + const OpBinaryMultiplyInt + const OpBinaryOr + const OpBinaryPower + const OpBinaryRShift + const OpBinarySubscr + const OpBinarySubtract + const OpBinarySubtractInt + const OpBinaryXor + const OpBuildList + const OpBuildMap + const OpBuildSet + const OpBuildString + const OpBuildTuple + const OpCall + const OpCallKw + const OpCallMethod + const OpClearException + const OpCompareEq + const OpCompareEqInt + const OpCompareEqJump + const OpCompareGe + const OpCompareGeInt + const OpCompareGeJump + const OpCompareGt + const OpCompareGtInt + const OpCompareGtJump + const OpCompareIn + const OpCompareIs + const OpCompareIsNot + const OpCompareLe + const OpCompareLeInt + const OpCompareLeJump + const OpCompareLt + const OpCompareLtInt + const OpCompareLtJump + const OpCompareLtLocalJump + const OpCompareNe + const OpCompareNeInt + const OpCompareNeJump + const OpCompareNotIn + const OpCopyDict + const OpDecrementFast + const OpDeleteAttr + const OpDeleteFast + const OpDeleteGlobal + const OpDeleteName + const OpDeleteSubscr + const OpDup + const OpDup2 + const OpEndFinally + const OpExceptStarMatch + const OpExceptStarReraise + const OpExceptionMatch + const OpExtractStar + const OpForIter + const OpGenStart + const OpGetAIter + const OpGetANext + const OpGetAwaitable + const OpGetIter + const OpGetLen + const OpImportFrom + const OpImportName + const OpImportStar + const OpIncrementFast + const OpInplaceAdd + const OpInplaceAnd + const OpInplaceDivide + const OpInplaceFloorDiv + const OpInplaceLShift + const OpInplaceMatMul + const OpInplaceModulo + const OpInplaceMultiply + const OpInplaceOr + const OpInplacePower + const OpInplaceRShift + const OpInplaceSubtract + const OpInplaceXor + const OpJump + const OpJumpIfFalse + const OpJumpIfFalseOrPop + const OpJumpIfTrue + const OpJumpIfTrueOrPop + const OpLenDict + const OpLenGeneric + const OpLenList + const OpLenString + const OpLenTuple + const OpListAppend + const OpLoadAttr + const OpLoadBuildClass + const OpLoadClosure + const OpLoadConst + const OpLoadConstLoadFast + const OpLoadDeref + const OpLoadEmptyDict + const OpLoadEmptyList + const OpLoadEmptyTuple + const OpLoadFalse + const OpLoadFast + const OpLoadFast0 + const OpLoadFast1 + const OpLoadFast2 + const OpLoadFast3 + const OpLoadFastLoadConst + const OpLoadFastLoadFast + const OpLoadGlobal + const OpLoadGlobalLoadFast + const OpLoadLocals + const OpLoadMethod + const OpLoadName + const OpLoadNone + const OpLoadOne + const OpLoadTrue + const OpLoadZero + const OpMakeCell + const OpMakeFunction + const OpMapAdd + const OpMatchClass + const OpMatchKeys + const OpMatchMapping + const OpMatchSequence + const OpMatchStar + const OpNegateFast + const OpNop + const OpPop + const OpPopExcept + const OpPopJumpIfFalse + const OpPopJumpIfTrue + const OpPrintExpr + const OpRaiseVarargs + const OpReturn + const OpRot2 + const OpRot3 + const OpSetAdd + const OpSetupAnnotations + const OpSetupExcept + const OpSetupExceptStar + const OpSetupFinally + const OpSetupWith + const OpStoreAttr + const OpStoreClosure + const OpStoreDeref + const OpStoreFast + const OpStoreFast0 + const OpStoreFast1 + const OpStoreFast2 + const OpStoreFast3 + const OpStoreFastLoadFast + const OpStoreGlobal + const OpStoreName + const OpStoreSubscr + const OpUnaryInvert + const OpUnaryNegative + const OpUnaryNot + const OpUnaryPositive + const OpUnpackEx + const OpUnpackSequence + const OpWithCleanup + const OpYieldFrom + const OpYieldValue + func (op Opcode) HasArg() bool + func (op Opcode) String() string + type PyBool struct + Value bool + func NewBool(v bool) *PyBool + func (b *PyBool) String() string + func (b *PyBool) Type() string + type PyBuiltinFunc struct + Fn func(args []Value, kwargs map[string]Value) (Value, error) + Name string + func (b *PyBuiltinFunc) String() string + func (b *PyBuiltinFunc) Type() string + type PyBytes struct + Value []byte + func NewBytes(v []byte) *PyBytes + func (b *PyBytes) String() string + func (b *PyBytes) Type() string + type PyCell struct + Value Value + type PyClass struct + Bases []*PyClass + Dict map[string]Value + IsABC bool + Metaclass *PyClass + Mro []*PyClass + Name string + RegisteredSubclasses []*PyClass + Slots []string + func (c *PyClass) String() string + func (c *PyClass) Type() string + type PyClassMethod struct + Func Value + func (c *PyClassMethod) String() string + func (c *PyClassMethod) Type() string + type PyCode struct + Code *CodeObject + func (c *PyCode) String() string + func (c *PyCode) Type() string + type PyComplex struct + Imag float64 + Real float64 + func MakeComplex(real, imag float64) *PyComplex + func NewComplex(real, imag float64) *PyComplex + func (c *PyComplex) String() string + func (c *PyComplex) Type() string + type PyCoroutine struct + Code *CodeObject + Frame *Frame + Name string + State GeneratorState + YieldValue Value + func (c *PyCoroutine) String() string + func (c *PyCoroutine) Type() string + type PyDict struct + Items map[Value]Value + func NewDict() *PyDict + func (d *PyDict) DictContains(key Value, vm *VM) bool + func (d *PyDict) DictDelete(key Value, vm *VM) bool + func (d *PyDict) DictGet(key Value, vm *VM) (Value, bool) + func (d *PyDict) DictLen() int + func (d *PyDict) DictSet(key, value Value, vm *VM) + func (d *PyDict) Keys(vm *VM) []Value + func (d *PyDict) String() string + func (d *PyDict) Type() string + type PyException struct + Args *PyTuple + Cause *PyException + Context *PyException + ExcType *PyClass + Instance *PyInstance + Message string + Notes *PyList + Traceback []TracebackEntry + TypeName string + func (e *PyException) Error() string + func (e *PyException) String() string + func (e *PyException) Type() string + type PyFloat struct + Value float64 + func NewFloat(v float64) *PyFloat + func (f *PyFloat) String() string + func (f *PyFloat) Type() string + type PyFrozenSet struct + Items map[Value]struct{} + func (s *PyFrozenSet) FrozenSetAdd(value Value, vm *VM) + func (s *PyFrozenSet) FrozenSetContains(value Value, vm *VM) bool + func (s *PyFrozenSet) FrozenSetLen() int + func (s *PyFrozenSet) String() string + func (s *PyFrozenSet) Type() string + type PyFunction struct + Closure []*PyCell + Code *CodeObject + Defaults *PyTuple + Globals map[string]Value + IsAbstract bool + Name string + func (f *PyFunction) String() string + func (f *PyFunction) Type() string + type PyGenerator struct + Code *CodeObject + Frame *Frame + Name string + State GeneratorState + YieldValue Value + func (g *PyGenerator) String() string + func (g *PyGenerator) Type() string + type PyGoFunc struct + Fn GoFunction + Name string + func NewGoFunction(name string, fn GoFunction) *PyGoFunc + func (g *PyGoFunc) String() string + func (g *PyGoFunc) Type() string + type PyInstance struct + Class *PyClass + Dict map[string]Value + Slots map[string]Value + func (i *PyInstance) String() string + func (i *PyInstance) Type() string + type PyInt struct + BigValue *big.Int + Value int64 + func MakeBigInt(v *big.Int) *PyInt + func MakeInt(v int64) *PyInt + func NewInt(v int64) *PyInt + func (i *PyInt) BigIntValue() *big.Int + func (i *PyInt) IsBig() bool + func (i *PyInt) String() string + func (i *PyInt) Type() string + type PyIterator struct + Index int + Items []Value + func (i *PyIterator) String() string + func (i *PyIterator) Type() string + type PyList struct + Items []Value + func NewList(items []Value) *PyList + func (l *PyList) String() string + func (l *PyList) Type() string + type PyMethod struct + Func *PyFunction + Instance Value + func (m *PyMethod) String() string + func (m *PyMethod) Type() string + type PyModule struct + Dict map[string]Value + Doc string + Loader Value + Name string + Package string + Spec Value + func NewModule(name string) *PyModule + func (m *PyModule) Get(name string) (Value, bool) + func (m *PyModule) Set(name string, value Value) + func (m *PyModule) String() string + func (m *PyModule) Type() string + type PyNone struct + func (n *PyNone) String() string + func (n *PyNone) Type() string + type PyNotImplementedType struct + func (n *PyNotImplementedType) String() string + func (n *PyNotImplementedType) Type() string + type PyObject interface + String func() string + Type func() string + type PyPanicError struct + ExcType string + Message string + func (e *PyPanicError) Error() string + type PyProperty struct + Doc string + Fdel Value + Fget Value + Fset Value + func (p *PyProperty) String() string + func (p *PyProperty) Type() string + type PyRange struct + Start int64 + Step int64 + Stop int64 + func (r *PyRange) Contains(val int64) bool + func (r *PyRange) Len() int64 + func (r *PyRange) String() string + func (r *PyRange) Type() string + type PySet struct + Items map[Value]struct{} + func (s *PySet) SetAdd(value Value, vm *VM) + func (s *PySet) SetContains(value Value, vm *VM) bool + func (s *PySet) SetLen() int + func (s *PySet) SetRemove(value Value, vm *VM) bool + func (s *PySet) String() string + func (s *PySet) Type() string + type PySlice struct + Start Value + Step Value + Stop Value + func (s *PySlice) String() string + func (s *PySlice) Type() string + type PyStaticMethod struct + Func Value + func (s *PyStaticMethod) String() string + func (s *PyStaticMethod) Type() string + type PyString struct + Value string + func InternString(s string) *PyString + func NewString(v string) *PyString + func (s *PyString) String() string + func (s *PyString) Type() string + type PySuper struct + Instance Value + StartIdx int + ThisClass *PyClass + func (s *PySuper) String() string + func (s *PySuper) Type() string + type PyTuple struct + Items []Value + func NewTuple(items []Value) *PyTuple + func (t *PyTuple) String() string + func (t *PyTuple) Type() string + type PyUserData struct + Metatable *PyDict + Value any + func NewUserData(v any) *PyUserData + func (u *PyUserData) String() string + func (u *PyUserData) Type() string + type TimeoutError struct + Timeout time.Duration + func (e *TimeoutError) Error() string + type TracebackEntry struct + Filename string + Function string + Line int + type TypeMetatable struct + Methods map[string]GoFunction + Name string + Properties map[string]GoFunction + func GetRegisteredTypeMetatable(typeName string) *TypeMetatable + func (mt *TypeMetatable) SetMethod(name string, fn GoFunction) + func (mt *TypeMetatable) SetMethods(methods map[string]GoFunction) + type VM struct + FileImporter func(filename string) (*CodeObject, error) + Globals map[string]Value + SearchPaths []string + func NewVM() *VM + func (vm *VM) ApplyPendingBuiltins() + func (vm *VM) ArgError(n int, msg string) + func (vm *VM) Call(callable Value, args []Value, kwargs map[string]Value) (Value, error) + func (vm *VM) CallDunder(inst *PyInstance, name string, args ...Value) (Value, bool) + func (vm *VM) CallDunderWithError(inst *PyInstance, name string, args ...Value) (Value, bool, error) + func (vm *VM) CallFunction(fn *PyFunction, args []Value, kwargs map[string]Value) (Value, error) + func (vm *VM) CheckBool(n int) bool + func (vm *VM) CheckDict(n int) *PyDict + func (vm *VM) CheckFloat(n int) float64 + func (vm *VM) CheckInt(n int) int64 + func (vm *VM) CheckList(n int) *PyList + func (vm *VM) CheckString(n int) string + func (vm *VM) CheckUserData(n int, typeName string) *PyUserData + func (vm *VM) CompareOp(op Opcode, a, b Value) Value + func (vm *VM) ComputeC3MRO(class *PyClass, bases []*PyClass) ([]*PyClass, error) + func (vm *VM) CoroutineSend(coro *PyCoroutine, value Value) (Value, bool, error) + func (vm *VM) CoroutineThrow(coro *PyCoroutine, excType, excValue Value) (Value, bool, error) + func (vm *VM) Equal(a, b Value) bool + func (vm *VM) EvalInNamespace(code *CodeObject, globals, locals map[string]Value) (Value, error) + func (vm *VM) Execute(code *CodeObject) (Value, error) + func (vm *VM) ExecuteInModule(code *CodeObject, mod *PyModule) error + func (vm *VM) ExecuteInNamespace(code *CodeObject, globals, locals map[string]Value) error + func (vm *VM) ExecuteWithContext(ctx context.Context, code *CodeObject) (Value, error) + func (vm *VM) ExecuteWithTimeout(timeout time.Duration, code *CodeObject) (Value, error) + func (vm *VM) GeneratorClose(gen *PyGenerator) error + func (vm *VM) GeneratorSend(gen *PyGenerator, value Value) (Value, bool, error) + func (vm *VM) GeneratorThrow(gen *PyGenerator, excType, excValue Value) (Value, bool, error) + func (vm *VM) Get(idx int) Value + func (vm *VM) GetBuiltin(name string) Value + func (vm *VM) GetGlobal(name string) Value + func (vm *VM) GetIntIndex(v Value) (int64, error) + func (vm *VM) GetModule(name string) (*PyModule, bool) + func (vm *VM) GetTop() int + func (vm *VM) GetTypeMetatable(typeName string) *TypeMetatable + func (vm *VM) HashValue(v Value) uint64 + func (vm *VM) ImportModule(name string) (*PyModule, error) + func (vm *VM) IsInstanceOf(inst *PyInstance, cls *PyClass) bool + func (vm *VM) NewTypeMetatable(typeName string) *TypeMetatable + func (vm *VM) NewUserDataWithMeta(v any, typeName string) *PyUserData + func (vm *VM) OptionalBool(pos int, def bool) bool + func (vm *VM) OptionalFloat(pos int, def float64) float64 + func (vm *VM) OptionalInt(pos int, def int64) int64 + func (vm *VM) OptionalString(pos int, def string) string + func (vm *VM) Pop() Value + func (vm *VM) Push(v Value) + func (vm *VM) RaiseError(format string, args ...any) + func (vm *VM) Register(name string, fn GoFunction) + func (vm *VM) RegisterBuiltin(name string, fn GoFunction) + func (vm *VM) RegisterFuncs(funcs map[string]GoFunction) + func (vm *VM) RegisterModule(name string, loader ModuleLoader) + func (vm *VM) RegisterModuleInstance(name string, module *PyModule) + func (vm *VM) RegisterType(typeName string, constructor GoFunction, methods map[string]GoFunction) + func (vm *VM) Repr(v Value) string + func (vm *VM) RequireArgs(name string, min int) bool + func (vm *VM) Run(code *CodeObject) (Value, error) + func (vm *VM) SetBuiltin(name string, v Value) + func (vm *VM) SetCheckInterval(n int64) + func (vm *VM) SetGlobal(name string, v Value) + func (vm *VM) SetTop(n int) + func (vm *VM) ToBool(n int) bool + func (vm *VM) ToFloat(n int) float64 + func (vm *VM) ToInt(n int) int64 + func (vm *VM) ToList(v Value) ([]Value, error) + func (vm *VM) ToString(n int) string + func (vm *VM) ToUserData(n int) *PyUserData + func (vm *VM) Truthy(v Value) bool + func (vm *VM) TypeError(expected string, got Value) + func (vm *VM) TypeNameOf(v Value) string + type Value any + func FromGoValue(v any) Value