On 8/19/07, Neal Norwitz <[EMAIL PROTECTED]> wrote: > I just fixed a bug in the new memoryview that used PyObject_DEL which > caused a problem in debug mode. I had to change it to a Py_DECREF. > It seems we have a lot of spellings of ways to free an object and I > wonder if there are more problems lurking in there. > > $ cat */*.c | grep -c PyObject_Del > 103 > $ cat */*.c | grep -c PyObject_DEL > 16 > $ cat */*.c | grep -c PyObject_Free > 16 > $ cat */*.c | grep -c PyObject_FREE > 19 > > I don't know how many of these are correct or incorrect. > > Note in Include/objimpl, the Del and Free variants are the same. I > plan to get rid of one of them. > > #define PyObject_Del PyObject_Free > #define PyObject_DEL PyObject_FREE > > PyObject_{MALLOC,REALLOC,FREE} depend upon whether python is compiled > with debug mode, pymalloc, or not. > > What are the rules for when a particular API should be used (or not > used) to free an object?
If you read the comment at the top of Include/objimpl.h, it says that PyObject_(New|NewVar|Del) are for object allocation while PyObject_(Malloc|Realloc|Free) are just like malloc/free, but they use pymalloc instead of the system malloc. After that there are the usual performance macros. I am sure that prefixing the pymalloc versions of malloc/free PyObject is confusing for people. Maybe that can change to something like PyMalloc_* or something to disambiguate better. -Brett _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com