Rationale behind the deprecation of __getslice__?

Steven Bethard steven.bethard at gmail.com
Thu Dec 9 18:52:32 EST 2004


Carl Banks wrote:
> Steven Bethard wrote:
> 
>>Unfortunately, I don't think __getslice__ can be removed from
>>list (and str and tuple) because of backwards compatibility 
>>constraints...
> 
> Wouldn't it work to have __getslice__ call __getitem__?  And, since
> that would be too much of a performance hit, have it check whether its
> type is list (or str or tuple), and only call __getitem__ if it is not
> (i.e., only for subclasses).  I don't think that would be too bad.
> 
> Subclasses would still be free to override __getslice__, but wouldn't
> have to.

Yeah, that doesn't seem like it would be too bad.  Probably someone 
would have to actually run some benchmarks to see what kind of 
performance hit you get...  But it would definitely solve the OP's 
problem...

Steve



More information about the Python-list mailing list