abstract

package
v0.12.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package abstract ports the gating subset of cpython/Objects/abstract.c. It dispatches the object protocol (length, get/set item, numeric operations, iteration) through the type slot table in objects.

Index

Constants

This section is empty.

Variables

View Source
var ErrTypeError = errors.New("TypeError")

ErrTypeError is the v0.2 placeholder for PyExc_TypeError. v0.3 wires up the real exception machinery.

CPython: Objects/exceptions.c:L2196 PyExc_TypeError

Functions

func Absolute added in v0.7.0

func Absolute(o objects.Object) (objects.Object, error)

Absolute dispatches abs(o) through nb_absolute.

CPython: Objects/abstract.c:1213 PyNumber_Absolute

func Add

func Add(a, b objects.Object) (objects.Object, error)

Add dispatches a + b through the numeric slots. Falls back to b's reflected slot when a returns NotImplemented.

CPython: Objects/abstract.c:L971 PyNumber_Add

func Divmod added in v0.7.0

func Divmod(a, b objects.Object) (objects.Object, error)

Divmod dispatches divmod(a, b) through nb_divmod, mirroring the fallback path PyNumber_Divmod uses when both operands share a type.

CPython: Objects/abstract.c:1129 PyNumber_Divmod

func GetItem

func GetItem(o, key objects.Object) (objects.Object, error)

GetItem fetches o[key]. For sequence types, key must be an int. Mapping types accept any hashable key.

CPython: Objects/abstract.c:L138 PyObject_GetItem

func Iter

func Iter(o objects.Object) (objects.Object, error)

Iter returns an iterator for o.

CPython: Objects/abstract.c:L2873 PyObject_GetIter

func IterNext

func IterNext(it objects.Object) (objects.Object, error)

IterNext advances an iterator. Returns ErrStopIteration when the iterator is exhausted, mirroring PyIter_Next.

CPython: Objects/abstract.c:L2895 PyIter_Next

func Length

func Length(o objects.Object) (int, error)

Length returns the length of o. Tries the sequence slot first, then the mapping slot, matching PyObject_Length.

CPython: Objects/abstract.c:L48 PyObject_Length

func Multiply

func Multiply(a, b objects.Object) (objects.Object, error)

Multiply dispatches a * b.

CPython: Objects/abstract.c:L1021 PyNumber_Multiply

func Power added in v0.7.0

func Power(a, b, mod objects.Object) (objects.Object, error)

Power dispatches pow(a, b, mod) through nb_power.

CPython: Objects/abstract.c:1107 PyNumber_Power

func SetItem

func SetItem(o, key, value objects.Object) error

SetItem assigns o[key] = value.

CPython: Objects/abstract.c:L194 PyObject_SetItem

func Subtract

func Subtract(a, b objects.Object) (objects.Object, error)

Subtract dispatches a - b.

CPython: Objects/abstract.c:L1013 PyNumber_Subtract

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL