Python C API String Memory Consumption

Benjamin Peterson benjamin at python.org
Tue Apr 7 10:12:24 EDT 2009


Carl Banks <pavlovevidence <at> gmail.com> writes:
> However, Python apparently does leak a reference if passed a Unicode
> object; PyArg_ParseTuple automatically creates an encoded string but
> never decrefs it.  (That might be necessary evil to preserve
> compatibility, though.  PyString_AS_STRING does it too.)

Unicode objects cache a copy of themselves as default encoded strings. It is
deallocated when the unicode object its self is.







More information about the Python-list mailing list