Tim Peters <tim.one@comcast.net> writes: > Are "the right" alloc/dealloc macros documented anywhere? I can't > find it, if they are. http://www.python.org/doc/current/api/memoryInterface.html is as precise and comprehensive as anything I would have written myself. The Examples even give explicit examples what cases to avoid. For PyObject, the equivalent documentation is at http://www.python.org/doc/current/api/allocating-objects.html > Much of a pymalloc fan as I am, I'm -1 on introducing it if we can't > give extension authors a clear, brief, prominent and self-contained > account of the memory rules they're supposed to follow (I don't > really know what they are -- I always reverse-engineer it as needed, > because I never found a place in the docs that offered sufficient > guidance). Do you think you would understand the documentation that is currently there? BTW, I found the documentation by grepping for PyMem_ in all .tex files, because I could not be bothered to read the online version, either. It leaves out a good many details (i.e. additional API), but I think this is deliberate - you are not supposed to ever use this other API, anyway. > > A lot of extensions will break. The example code in xxmodule.c was > > "wrong" for years. > > Ditto Zope (as Guido said), ditto Marc-Andre's extensions, ditto NumPy > (IIRC), yadda yadda yadda. I don't know whether MarkH has tried the massive > Win32 extensions with pymalloc yet. I wonder whether one could design a script that analyses Python code for asymmetric usage of memory management functions, e.g. trying to match expression->FIELD = ALLOCATOR; DEALLOCATOR(other_expression->FIELD); This would complain if there is a FIELD that has no symmetric usage, or if a certain allocator has no counterpart at all in a source file. I then wonder if that script would have found the errors you cite. Regards, Martin
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4