[Python-ideas] List Revolution
Terry Reedy
tjreedy at udel.edu
Mon Sep 12 23:26:26 CEST 2011
On 9/12/2011 2:05 AM,
mike.w.meyer at gmail.com wrote:
> Ok, how about enhancing the list type to allow specifying an offset,
Because then every list index/slice access would require more time to
subtract the offset.
> defaulting to 0? The offset should be positive, and that many
> elements simple aren't there. Asking for an element that isn't there,
> or a slice including such an element, raises value error exception.
Slicing never raises a ValueError. In particular, seq[0:1] always
returns a sequence with 1 or 0 items. This is an important feature.
> The iterators& etc for this list would all start at offset instead
> of zero.
Write a list subclass. Decide how you would handle indexing from the
right (currently all negative indexes) and implement that.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list