Rationale behind the deprecation of __getslice__?
Fernando Perez
fperez528 at yahoo.com
Thu Dec 9 21:37:04 EST 2004
Terry Reedy wrote:
>
>> If no __getslice__() is found, a slice object is created instead, and
>> passed to __getitem__() instead.
>
> The overwhelmingl most common case of a simple slice is more efficiently
> done by having a separate function since no slice object is created.
>
>>>> a=[1,2,3]
>>>> def f(): return a[0:1]
> ...
>>>> import dis
>>>> dis.dis(f)
[...]
Very good point. I always forget how useful dis is, thanks.
f
More information about the Python-list
mailing list