PyArg_ParseTuple() & Py_DECREF()

Fredrik Lundh effbot at telia.com
Sat Mar 4 13:52:25 EST 2000


Alex Farber <farber at cpan.org> wrote:
> Thanks for your answer, but I still don't understand:
> if Python reserves some memory via malloc() for that string
> and assigns it to the pointer str

the string is owned by the string object.

looking at the PyStringObject struct and the AS_STRING
macro in include/stringobject.h might help.

> who will free that memory?

Python.  the string pointer is valid as long as the object
is alive (in other words, if you wish to keep the pointer
around, you must make sure to keep a reference to the
string object as well).

</F>





More information about the Python-list mailing list