Documentation
¶
Overview ¶
Package gc ports the refcount-only path of cpython/Python/gc.c. v0.3 ships Track, Untrack, RegisterFinalizer, and Finalize. Cycle collection is a no-op until v0.10 lands the cycle collector.
CPython: Python/gc.c file overview
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Collect ¶
func Collect() int
Collect runs the cycle collector. v0.3 has none, so this returns 0. The signature is preserved so callers compile against v0.10 without changes.
CPython: Modules/gcmodule.c:L1430 gc_collect_main
func Finalize ¶
Finalize runs the finalizer for o exactly once and clears it. Safe to call on objects that never registered one. Mirrors PyObject_CallFinalizerFromDealloc.
CPython: Objects/object.c:L497 PyObject_CallFinalizerFromDealloc
func IsTracked ¶
IsTracked reports whether o is currently tracked.
CPython: Include/internal/pycore_object.h:L268 _PyObject_GC_IS_TRACKED
func RegisterFinalizer ¶
RegisterFinalizer associates fn with o. The runtime calls Finalize to invoke it. Mirrors PyObject_GC_RegisterFinalizer in spirit; in CPython the per-object slot is tp_finalize, but gopy keeps the mapping out-of-band so Header stays small.
CPython: Objects/object.c:L489 PyObject_CallFinalizer (caller side)