[Patches] [ python-Patches-663983 ] PyList_NewNoZero

SourceForge.net noreply@sourceforge.net
Sat, 11 Jan 2003 03:56:55 -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: Closed
Resolution: Rejected
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.

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-01-07 15:51

Message:
Logged In: YES 
user_id=6380

I'm not comfortable with this, I find it hard to believe
that a memset() can make much difference given everything
else that goes on (like INCREF'ing every single thing that
gets stored in a list even by PyList_SET_ITEM), I see no
performance data backing up the change, and I would like to
keep the annual growth of Python within bounds. So, -1.

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

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