(original) (raw)

On Sat, Apr 27, 2019, 04:27 Armin Rigo <armin.rigo@gmail.com> wrote:
Hi Neil,

On Wed, 24 Apr 2019 at 21:17, Neil Schemenauer <nas-python@arctrix.com> wrote:
\> Regarding the Py\_TRACE\_REFS fields, I think we can't do them without
\> breaking the ABI because of the following. For GC objects, they are
\> always allocated by \_PyObject\_GC\_New/\_PyObject\_GC\_NewVar. So, we
\> can allocate the extra space needed for the GC linked list. For
\> non-GC objects, that's not the case. Extensions can allocate using
\> malloc() directly or their own allocator and then pass that memory
\> to be initialized as a PyObject.
\>
\> I think that's a poor design and I think we should try to make slow
\> progress in fixing it.

Such progress needs to start with the global static PyTypeObjects that
all extensions define. This is going to be impossible to fix without
requiring a big fix in of \*all\* of them. (Unless of course you mean
to still allow them, but then Py\_TRACE\_REF can't be implemented in a
way that doesn't break the ABI.)

For Py\_TRACE\_REFS specifically, IIUC the only goal is to be able to produce a list of all live objects on demand. If that's the goal, then static type objects aren't a huge deal. You can't add extra data into the type objects themselves, but since there's a fixed set of them and they're immortal, you can just build a static list of all of them in PyType\_Ready.

-n