Hi, CPython maintainer here. What can we do to make this easier on Julia?
Currently, we expose the size of the PyTypeObject
structure in the debug offsets. (Discourse won’t let me post links, but check out the _Py_DebugOffsets
structure in the pycore_debug_offsets.h
file.) Is it possible for Julia to check the debug offsets to ensure that it’s mimicking the type object structure correctly?
Alternatively, it’d be nice if Julia didn’t have to use the PyTypeObject
structure at all. I’m assuming you guys are using it to define native types? If so, I think it’d be a lot easier to switch to heap types (PyType_Spec
), which use an array of slots instead of structure fields to avoid ABI compatibility issues.
Yeah, as I said on the linked PR there, I’m not fully convinced we should be documenting fields like tp_versions_used
. It’s an implementation detail used solely as an optimization by the interpreter, and it seems like people only want to know about it so they can mimick the type object structure (in which case, you should just use heap types).
Static types have a number of downsides:
- They’re implicitly immortal (see PEP 683).
- They have to be immutable for thread-safety reasons (see
Py_TPFLAGS_IMMUTABLETYPE
) - They cannot be used with multiple inheritance.