SV: PyArg_ParseTuple() & Py_DECREF()

Andrew M. Kuchling akuchlin at mems-exchange.org
Mon Mar 6 09:32:44 EST 2000


Alex Farber <farber at cpan.org> writes:
> 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, who will free that memory?
> Py__Finalize()? And if Python does not allocate any memory
> and uses some static storage, why won't it get overwritten
> by subsequent calls of PyArg_ParseTuple()?

Python returns a pointer into the string object, and the string object
will be freed whenever the string is no longer accessible and gets
garbage collected.  It should be emphasized that you must NOT modify
the string using that point, because that would break the language's
semantics -- you'd be mutating a string.

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
The words _figure_ and _fictitious_ both derive from the same Latin root
_fingere_. Beware!
    -- M.J. Moroney





More information about the Python-list mailing list