[Patches] [ python-Patches-663983 ] PyList_NewNoZero

SourceForge.net noreply@sourceforge.net
Tue, 07 Jan 2003 12:42:46 -0800


Patches item #663983, was opened at 2003-01-07 15:42
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=663983&group_id=5470

Category: Core (C code)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Raymond Hettinger (rhettinger)
Assigned to: Guido van Rossum (gvanrossum)
Summary: PyList_NewNoZero

Initial Comment:
PyList_New(n) spends time initializing every space to 
zero.  In many (but not all cases), the caller 
immediately refills in every space and has no error 
exits prior to filling the space.  In those cases, time 
would be saved by using a version of PyList_New(n) 
that did not do the initialization.

The same holds true for tuples.

Creating new lists and tuples is one of the most 
common operations in python and may warrant this 
micro-optimization.

The attached patch is a proof-of-concept.

The only downside is that it shares the same risks as 
it SET_ITEM macro cousins -- the user of the function 
has the burden of making sure that certain conditions 
hold (in the case, promising to fill out every entry with 
a valid python object or NULL).

Guido, what do you think?  If it gets a plus one, I can 
make a more thorough patch and get a detailed 
review.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=663983&group_id=5470