[issue29881] Add a new private API for "static C variables" (_PyStaticVar) to clear them at exit

STINNER Victor report at bugs.python.org
Thu Mar 23 06:27:16 EDT 2017


STINNER Victor added the comment:

Serhiy: "use gc_next/gc_refs for managing a linked list"

I'm not sure that I understand your idea. These fields are already used internally by the garbage collector. If I modify one of these fields, it would corrupt the GC, no?

Serhiy: "You can use a dynamic array of PyObject** instead of a linked list for collecting references to "static variables""

Ah yes, I like the idea of using a single array to track all variables. An array reduces memory fragmentation and is simple to maintain, since the API only needs two operations: list.append(obj) and list.clear(). The API already requires to check for errors, so another memory allocation failure wouldn't be suprising.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29881>
_______________________________________


More information about the Python-bugs-list mailing list