Nick Coghlan <ncogh...@gmail.com> added the comment:

I brought the patch up to date for the Py3k branch, but realised just before 
checking it in that it may run afoul of the language moratorium (since it 
alters the behaviour of builtin range objects).

However, the .count() and .index() methods (along with the Sequence ABC 
registration) as well as the O(1) containment testing for integers were already 
put in place. (I also noticed that the new methods from issue #9213 are not 
mentioned in the range() docs, unlike the O(1) optimisation)

I've gone ahead and checked it in as r86970, as I see this patch as filling out 
the promise of the Sequence ABC registration by adding support for slicing and 
negative indices (with the length caching as more of an implementation detail).

However, I'm also leaving the tracker issue open and assigning to Georg in case 
he wants to revert it before the beta goes out.

Note that I also fixed the patch so that OverflowError occurs only when 
encountering an affected operation (primarily indexing and retrieval of the 
length). If you don't do any of those things, you can make your ranges as large 
as you like. (The indexing could fairly easily be fixed to eliminate the 
overflow errors - I just didn't do it in this patch, since it is a separate 
problem).

----------
assignee:  -> georg.brandl
nosy: +georg.brandl
resolution:  -> accepted
stage: patch review -> committed/rejected
title: Precompute range length -> Precompute range length and enhance range 
subscript support
Added file: http://bugs.python.org/file19926/issue2690_lazy_overflow_check.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue2690>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to