[Python-3000] optimizing [x]range
Stargaming
stargaming at gmail.com
Thu Aug 2 18:19:29 CEST 2007
On Thu, 02 Aug 2007 15:03:42 +0000, Stargaming wrote:
> On Sat, 28 Jul 2007 17:06:50 +0200, tomer filiba wrote:
>
>> currently, testing for "x in xrange(y)" is an O(n) operation.
>>
>> since xrange objects (which would become range in py3k) are not real
>> lists, there's no reason that __contains__ be an O(n). it can easily be
>> made into an O(1) operation. here's a demo code (it should be trivial
>> to implement this in CPython)
[snipped algorithm]
>
> I gave the implementation a try.
[snipped patch details]
>
> Should I submit the patch to the SF patch manager as well?
Guido> Yes, please submit to SF.
Submitted to the SF patch manager as patch #1766304. It is marked as a
Python 2.6 item.
http://sourceforge.net/tracker/index.php?
func=detail&aid=1766304&group_id=5470&atid=305470
Regards,
Stargaming
More information about the Python-3000
mailing list