On Sat, Oct 15, 2011 at 10:28 AM, Nick Coghlan email@example.com wrote:
I have a use case now: switching slice.indices() to return a range object instead of a tuple. That heavily favours the 'behave like a sequence' approach.
I like the idea, but why is this a use-case for range.__eq__ or range.__hash__?
I like the idea not because it will lead to any optimisation. Slice.indices() does not return a tuple containing all indices in a slice. The result is always a 3-tuple containing normalized start, stop, and step. A range object cannot be more efficient than a 3-tuple.
I still like the idea because it would make indices() return what the name suggests - the sequence of indices selectable by the slice.