[Python-Dev] Range __contains__ and objects with __index__ methods

2010-12-26 Thread Nick Coghlan
Starting in Python 3.2, range() supports fast containment checking for integers (i.e. based on an O(1) arithmetic calculation rather than an O(N) iteration through the entire sequence). Currently, this fast path ignores objects that implement __index__ - they are relegated to the slow iterative

Re: [Python-Dev] Range __contains__ and objects with __index__ methods

2010-12-26 Thread Terry Reedy
On 12/26/2010 7:15 PM, Nick Coghlan wrote: Starting in Python 3.2, range() supports fast containment checking for integers (i.e. based on an O(1) arithmetic calculation rather than an O(N) iteration through the entire sequence). Currently, this fast path ignores objects that implement __index__

Re: [Python-Dev] Range __contains__ and objects with __index__ methods

2010-12-26 Thread Martin v. Löwis
What are the actual used of .__index__? Can you please rephrase this question? Regards, Martin ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe:

Re: [Python-Dev] Range __contains__ and objects with __index__ methods

2010-12-26 Thread Nick Coghlan
On Mon, Dec 27, 2010 at 11:52 AM, Terry Reedy tjre...@udel.edu wrote: Return a converted to an integer. Equivalent to a.__index__(). comes close to implying equality (if possible). What are the actual used of .__index__? PEP 357 gives the original rationale - it was to allow integer-like