[Patches] [ python-Patches-551410 ] xrange() optimization

noreply@sourceforge.net noreply@sourceforge.net
Sat, 04 May 2002 06:31:20 -0700


Patches item #551410, was opened at 2002-05-02 15:39
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=551410&group_id=5470

Category: Core (C code)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Raymond Hettinger (rhettinger)
Assigned to: Nobody/Anonymous (nobody)
Summary: xrange() optimization

Initial Comment:
Performance improvement for xrange() when used in 
loops or list(xrange()).  Does NOT change external 
interface or restart characteristics.

Fills the tp_iter and tp_iternext slots to provide 
faster looping than access via sq_item wrapped by an 
iterobject.

Times about 25% faster than the original.  Brings
the performance to within 5 to 7% of range().

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

>Comment By: Martin v. Löwis (loewis)
Date: 2002-05-04 15:31

Message:
Logged In: YES 
user_id=21627

As currently implemented, there is an API change:
iter(xrange(10)) does not have a .next method anymore.

When revising the patch, please eliminate the extra 0,
before the new tp_ entries.

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

Comment By: Raymond Hettinger (rhettinger)
Date: 2002-05-04 03:08

Message:
Logged In: YES 
user_id=80475

Yes.  See new patch from current CVS rangeobject.c 2.35.

Timings still show 25% improvement coming to within 6% of 
range().  Passes \lib\test\test_builtin.py.

External interface unchanged, so docs left unchanged.

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

Comment By: Martin v. Löwis (loewis)
Date: 2002-05-02 22:18

Message:
Logged In: YES 
user_id=21627

Can you please update this patch to the current CVS
(rangeobject.c 2.35)?

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

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