[issue2041] __getslice__ still called

Mark Dickinson report at bugs.python.org
Thu Feb 7 19:44:22 CET 2008


Mark Dickinson added the comment:

I think the docs do a good job of explaining this;  in particular, they 
say, 
in http://docs.python.org/dev/reference/datamodel.html#special-method-
names:

"However, built-in types in CPython currently still implement 
__getslice__()."

and explain that __getslice__ is used only to implement the form a[i:j], 
and 
falls back to __getitem__ if __getslice__ is not implemented.

Getting rid of __getslice__ for builtin types in Python 2.x is probably 
one 
of those things that would break backwards compatibility.  And leaving 
it in 
is pretty harmless.  To avoid surprises, don't implement __getslice__ in 
your 
own classes.  But note that __getslice__ and friends are gone in Python 
3.0.

I'd recommend closing this as invalid, but I'll wait for a second 
opinion.

----------
nosy: +marketdickinson

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2041>
__________________________________


More information about the Python-bugs-list mailing list