Setu 2026.11.9
static
YoSTEALTH/Setu

Classes

A setu.Class per hook family: what Setu generates for each.

exception ExtraError(OSError)#

An OSError of the extension's own: ExtraError(errno, msg) sets .errno / .strerror.

exception PlainError(Exception)#

A plain Exception subclass.

class Mode#

Subclass of IntEnum.

How a call ended: an IntEnum (this file's from entry has .enums = .int_enum), every field a member.

value plain = <Mode.plain: 1>#

value with_errno = <Mode.with_errno: 2>#

value OTHER = <Mode.OTHER: 7>#

class Vec(x: int = ..., y: int = ...)#

A 2D vector with integer coordinates: comparisons, hashing, numbers, pickling.

method norm2() -> int#

The squared length.

method from_pair(x: int, y: int) -> Any#

A new vector of the class cls (a subclass too).

Example

>>> Vec.from_pair(1, 2)
Vec(1, 2)

method dot(a: Vec, b: Vec) -> int#

The dot product of two vectors.

Example

>>> Vec.dot(Vec(1, 2), Vec(3, 4))
11

method fill_into(buf: Buffer | None = None, scale: int | None = None) -> int#

Releases the buffer the last call kept, then keeps buf (a method's py.OwnedWritableBuffer) until the next call and fills it with x; fill_into() only releases. Returns how many bytes.

Example

>>> b = bytearray(2)
>>> Vec(7).fill_into(b)
2
>>> b
bytearray(b'\x07\x07')
>>> b.append(1)
BufferError: Existing exports of data: object cannot be re-sized

value DIMS = 2#

value NAME = 'Vec'#

value UNIT = 1.0#

class Labeled(label: Any | None = None)#

Subclass of Vec.

A Vec with a label: a Setu subclass, pickled with its base's fields.

property label: Any#

The label.

class Origin#

Subclass of Vec.

A Vec with no fields of its own: no instance data of its own (no Py_tp_extra_basicsize).

method is_zero() -> bool#

Is it (0, 0)?

class Ordered(rank: int)#

Only __lt__: still hashable (by identity), as a Python class would be.

property rank: int#

The rank (an int property).

Example

>>> o = Ordered(1)
>>> o.rank = 3
>>> o.rank
3

class Num(v: int)#

An integer with every number operator, to check the slots and the reflected ones.

class Bag(*args: Any, **kwargs: Any)#

A fixed-size container of up to 4 objects: len, [], in, del, iteration; generic (Bag[int]), with weakrefs and a __dict__.

class BagIter#

Iterates a Bag (its own iterator: __next__ without __iter__).

class Countdown(start: int)#

Counts down from start to 1 (__next__ returning ?u64); get_left() is a method (plain_methods), not a property.

method get_left() -> int#

How many numbers are left (a method, though it is named like a getter).

class Adder(base: int)#

Adds base to what it is called with (__call__).

method collect(first: int, /, *rest: int, **extra: int) -> tuple[int, tuple[int, ...], dict[str, int]]#

(first + base, rest, extra): a positional-only parameter, then *rest and **extra.

Type

rest int
extra int
return tuple[int, tuple[int, ...], dict[str, int]]

method count(*args: int) -> int#

The number of positional arguments: a method whose first parameter is *args.

Type

args int
return int

class Dyn#

Dynamic attributes: unknown names read as their length; assignments and deletions are counted (__getattr__, __setattr__, __delattr__).

property sets: int#

How many assignments.

property dels: int#

How many deletions.

class Slot(value: int)#

A descriptor holding one int: read from the class it is itself, from an instance its value; __set__ stores, __delete__ resets to 0.

class Watch(callback: Any)#

Calls callback() when finalized (__finalize__), with its fields still set; link makes a reference cycle for the GC to break.

class Later(result: Any)#

An awaitable (__poll__) that waits once in the event loop, then gives result.

class Pair(a, b=None)#

Two ints set in __new__ only (no __init__): the stub declares __new__. The property swapped comes from getset (py.getter), its stub line from stub; repr from slots (a C Py_tp_repr).

Type

b int | None a when not given

property pair: tuple[int, int]#

(a, b).

property swapped: tuple[int, int]#

(b, a).

class Slab#

A large instance whose buffer's default is undefined: tp_new writes only the defined defaults (the shape of Shakti's SQE; tool/bench.py times Slab()).

method push(byte: int) -> bool#

Appends byte; False when the slab is full.

Example

>>> s = Slab()
>>> s.push(7)
True
>>> s.used
1

property used: int#

The bytes pushed so far.

property total: int#

The sum of the bytes pushed.

raise_extra(errno: int, msg: str) -> None#

Raises ExtraError(errno, msg) (raiseWith).

Example

>>> raise_extra(95, 'not here')
ExtraError: [Errno 95] not here

raise_plain(n: int) -> None#

Raises PlainError with a formatted message (raise).

Example

>>> raise_plain(3)
PlainError: plain 3

is_plain(exc: Any) -> bool#

Is exc a PlainError (an instance or the class, or a subclass)? (matches)

Example

>>> is_plain(PlainError('x')), is_plain(ValueError())
(True, False)

overridden() -> int#

2 (extra.zig's overridden, which it replaces, gives 1).

Generated by tool/setu_doc.py from the docstrings of Setu 2026.11.9.