[Python-Dev] PEP 384: Defining a Stable ABI

Antoine Pitrou solipsis at pitrou.net
Fri May 22 19:00:00 CEST 2009


Jim Jewett <jimjjewett <at> gmail.com> writes:
> 
> > The accessor macros to these fields (Py_REFCNT, Py_TYPE, Py_SIZE)
> > are also available to applications.
> 
> There have been several experiments in memory management, ranging from
> not bothering to change the refcount on permanent objects like None,
> to proxying objects across multiple threads or processes.

These experiments don't seem to have been very successful, have they? Besides,
Py_TYPE is a fundamental property of every PyObject.

On the other hand, I think Py_SIZE should be discouraged in favour of the
type-specific variants (PyString_GET_SIZE, etc.), since some types have their
own way of (ab)using the size field.

> I also
> believe (but don't remember for sure) that some of the proposed
> Unicode (or String?) optimizations changed the memory layout a bit.

The one Unicode optimization I know of, in http://bugs.python.org/issue1943, is
suspended because of Marc-Andre's opposition. In any case, it doesn't touch the
fundamental PyObject layout.

Regards

Antoine.




More information about the Python-Dev mailing list