[Python-Dev] RFC: PEP 445: Add new APIs to customize Python memory allocators (original) (raw)

Antoine Pitrou solipsis at pitrou.net
Wed Jun 19 17:43:54 CEST 2013


On Wed, 19 Jun 2013 17:24:21 +0200 Victor Stinner <victor.stinner at gmail.com> wrote:

For the "track memory usage" use case, it is important to track memory allocated in external libraries to have accurate reports, because these allocations may be huge. [...] Not in main(). The Python expat and zlib modules call directly malloc() and may allocate large blocks. External libraries like OpenSSL or bz2 may also allocate large blocks.

Fair enough.

>> Drawback: the caller has to check if the result is 0, or handle the >> error. > > Or you can just call PyFatalError() if the domain is invalid.

I don't like PyFatalError(), especially when Python is embedded. It's safer to return -1 and expect the caller to check for the error case.

I don't think you need to check for errors. The domain is always one of the existing constants, i.e. it should be hard-coded in the source, not computed.

Regards

Antoine.



More information about the Python-Dev mailing list