[Python-Dev] Moving forward on the object memory API (original) (raw)

Tim Peters tim.one@comcast.net
Mon, 01 Apr 2002 09:41:57 -0500


[Tim]

Read the tail end of the PyMem docs (PyMemUPPERCASE is supposedly already deprecated, but only in extension modules).

[martin@v.loewis.de]

There is something wrong here, then.

That's for sure .

The author of this documentation clearly meant that they are internal, and thus should have been called PyMemUPPERCASE.

I doubt the author meant that: in 1.5.2, PyMem_DEL was the only "legal" way to free object memory, and even if people didn't know that from reading the docs, they picked it up via copying Python's Objects/xxmodule.c (which used PyMem_DEL through revision 2.15).

I'd be in favour of renaming them, thus actively breaking extension modules that use them at compile time.

That would break every extension type written for 1.5.2; the relevant ones from Neil's random sampling are:

DB2-Python-0.991 Allocates with PyObject_NEW and deallocates with PyMem_DEL

DCOracle-1.3.1b1 Allocates with PyObject_NEW and deallocates with PyMem_DEL

Kinterbasdb Allocates with PyObject_NEW and deallocates with PyMem_DEL

PyGreSQL-3.3-pre011203 Allocates with PyObject_NEW and deallocates with PyMem_DEL

avl-2.0 Allocates with PyObject_NEW and deallocates with PyMem_DEL

sybase-0.33 Allocates with PyObject_NEW and deallocates with PyMem_DEL

pysdl-0.0.7 Allocates with PyObject_NEW and deallocates with PyMem_DEL

pyshout-0.0.6 Allocates with PyObject_NEW and deallocates with PyMem_DEL

pwin Allocates with PyObject_NEW and deallocates with PyMem_DEL

I'm all in favor of deprecating PyMem_DEL, so long as deprecation doesn't mean anything <wink -- but the sampling above tells me how seriously people have taken the existing claim of deprecation>.

An alternative-- which no longer poses an implementation problem --is to say that from 2.3 onward, PyMem_Del, PyMem_DEL, PyObject_Del, PyObject_DEL, PyObject_FREE, and PyObject_Free, are all exactly the same thing (as has always been true in reality, except when pymalloc was enabled in 2.2 or before). At least 4 of those spellings should be deprecated then, but gently. Whether PyMem_Free and PyMem_FREE also belong in that pile isn't clear.