Python C API Question.

Jeff Epler jepler at unpythonic.net
Sat Oct 23 11:09:30 EDT 2004


Please see
http://docs.python.org/api/listObjects.html

C's PyList_Append() is roughly equivalent to Python's list.append().
If you want to construct a list without knowing how many items will
eventually be in it, use PyList_New(0), then PyList_Append for each
item you want to add.  This will be as efficient as the similar
Python code
    l = [f(x) for x in s]
in terms of the number of resizes the internal array-of-pointers
undergoes.

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20041023/bf88d1ba/attachment.sig>


More information about the Python-list mailing list