[issue25135] Deques to adopt the standard clearing procedure for mutable objects

Tim Peters report at bugs.python.org
Fri Sep 25 20:51:34 CEST 2015


Tim Peters added the comment:

The only way to be certain you're never going to face re-entrancy issues in the future is to call malloc() directly - and hope nobody redefines that too with some goofy macro ;-)

In the meantime, stick to PyMem_Malloc().  That's the intended way for code holding the GIL to do lowest-level memory allocation.  Uses of PyMem_RawMalloc() should be extremely rare, typically only in contexts where Python internals _know_ the GIL isn't being held, and can't reasonably try to acquire the GIL.  It's already being used in a few contexts where it probably shouldn't be, and each such use needlessly complicates future changes.

If PyMem_Malloc() does grow re-entrancy issues in the future, deques will be the least of our problems.  I'd strongly oppose it before then.  It's _intended_ to be as low level as possible (it was created to begin with just to worm around cross-platform insanity when called with a 0 argument).

----------
nosy: +tim.peters

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25135>
_______________________________________


More information about the Python-bugs-list mailing list