[Patches] [ python-Patches-1002085 ] O(1) xrange membership testing

SourceForge.net noreply at sourceforge.net
Mon Aug 2 19:28:42 CEST 2004


Patches item #1002085, was opened at 2004-08-02 18:43
Message generated for change (Comment added) made by ronaldoussoren
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1002085&group_id=5470

Category: Core (C code)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Mac-arena the Bored Zo (boredzo)
Assigned to: Nobody/Anonymous (nobody)
Summary: O(1) xrange membership testing

Initial Comment:
this patch applies to anonymous CVS as of 2004-08-02 at 07:
54:58 PDT.

it adds O(1) membership testing; for example:

Python 2.4a1+ (#2, Aug  2 2004, 09:11:43) 
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on 
darwin
Type "help", "copyright", "credits" or "license" for more 
information.
>>> import sys
>>> sys.maxint
2147483647
>>> sys.maxint in xrange(sys.maxint)
False

in current CVS, this would take untold hours to complete 
(because Python arrives at this answer by iterating on the 
sequence). this patch adds a __contains__ method to the 
xrange object which examines the xrange's pattern and 
determines the correct answer instantly based on that pattern.

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

Comment By: Ronald Oussoren (ronaldoussoren)
Date: 2004-08-02 19:28

Message:
Logged In: YES 
user_id=580910

You forgot to add the patch (did you check the checkbox?).

BTW. Does your patch include unittests?

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

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


More information about the Patches mailing list