memory leak - C API

John Hunter jdhunter at ace.bsd.uchicago.edu
Fri Dec 5 16:13:00 EST 2003


>>>>> "Tim" == Tim Peters <tim.one at comcast.net> writes:

    Tim> Where did that understanding come from?  It's important to
    Tim> track it down, because whatever source you got it from is
    Tim> unreliable.  This one is such a common misconception that the
    Tim> docs (Python C/API Reference Manual, section "Reference Count
    Tim> Details") point it out explicitly:

Argg... I got it from reading the API for PyList_GetItem and
*assuming* it worked the same way for PySequence_GetItem.  I was using
the PyList API as a stand-in for the sequence API because I didn't
find the PySequence API.

I ended up at
http://www.python.org/doc/current/api/sequenceObjects.html by
googling.  Perhaps the best way to help others avoid making the same
mistake is to make a link on the
http://www.python.org/doc/current/api/sequenceObjects.html page to
http://www.python.org/doc/current/api/sequence.html page, which I only
found after reading your post.

Eg, on http://www.python.org/doc/current/api/sequenceObjects.html,
something like 

  For generic operations on sequence objects, see the sequence
  protocol <a
  href=http://www.python.org/doc/current/api/sequence.html>PySequence<a/>;
  this section deals with the specific kinds of sequence objects that
  are intrinsic to the Python language.

The link "PySequence" would have caught my eye (since I was looking
for it), but the bland

  Generic operations on sequence objects were discussed in the
  previous chapter; this section deals with the specific kinds of
  sequence objects that are intrinsic to the Python language.

did not.

Thanks for the help, 
John Hunter





More information about the Python-list mailing list