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 ¶
- Variables
- func Absolute(o objects.Object) (objects.Object, error)
- func Add(a, b objects.Object) (objects.Object, error)
- func Divmod(a, b objects.Object) (objects.Object, error)
- func GetItem(o, key objects.Object) (objects.Object, error)
- func Iter(o objects.Object) (objects.Object, error)
- func IterNext(it objects.Object) (objects.Object, error)
- func Length(o objects.Object) (int, error)
- func Multiply(a, b objects.Object) (objects.Object, error)
- func Power(a, b, mod objects.Object) (objects.Object, error)
- func SetItem(o, key, value objects.Object) error
- func Subtract(a, b objects.Object) (objects.Object, error)
Constants ¶
This section is empty.
Variables ¶
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
Absolute dispatches abs(o) through nb_absolute.
CPython: Objects/abstract.c:1213 PyNumber_Absolute
func Add ¶
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
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 ¶
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 IterNext ¶
IterNext advances an iterator. Returns ErrStopIteration when the iterator is exhausted, mirroring PyIter_Next.
CPython: Objects/abstract.c:L2895 PyIter_Next
func Length ¶
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 Power ¶ added in v0.7.0
Power dispatches pow(a, b, mod) through nb_power.
CPython: Objects/abstract.c:1107 PyNumber_Power
Types ¶
This section is empty.