Documentation
¶
Overview ¶
Package arena is a bump allocator with a linked list of fixed-size blocks. It mirrors cpython/Python/pyarena.c and serves the compiler pipeline (parser, AST, symtable, codegen) where many small nodes share a single lifetime.
The arena is not safe for concurrent use. Callers serialize externally, the same as CPython.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Arena ¶
type Arena struct {
// contains filtered or unexported fields
}
Arena is a bump allocator. The zero value is not usable; call New.
CPython: Python/pyarena.c:L43 _arena
func New ¶
func New() *Arena
New returns an arena with one preallocated block.
CPython: Python/pyarena.c:L125 _PyArena_New
func (*Arena) AddObject ¶
AddObject registers obj so it is retained until Free is called. The error return mirrors the C call shape; in practice the value is always nil.
CPython: Python/pyarena.c:L200 _PyArena_AddPyObject
func (*Arena) Free ¶
func (a *Arena) Free()
Free drops every block and tracked object, so the GC can reclaim them. The arena must not be used after Free.
CPython: Python/pyarena.c:L154 _PyArena_Free
func (*Arena) Malloc ¶
Malloc returns a byte slice of length n carved out of the current block, allocating a new block if needed. The slice is capped so callers cannot append into the next allocation. n is rounded up to the alignment boundary; the returned slice has the rounded length, matching what _PyArena_Malloc hands out in C.
CPython: Python/pyarena.c:L177 _PyArena_Malloc