classification
Title: __getitem__() doesn't capture all slices if class inherits from list, tuple or str
Type: performance Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, johnf
Priority: normal Keywords:

Created on 2008-07-27 19:58 by johnf, last changed 2008-07-27 21:17 by amaury.forgeotdarc. This issue is now closed.

Files
File name Uploaded Description Edit
getitem_problem.py johnf, 2008-07-27 19:58
Messages (1)
msg70329 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-07-27 21:17
When executing self[i:j], the __getslice__(self,i,j) method is called
first, if it exists. See
http://docs.python.org/ref/sequence-methods.html

Yes, the __(get|set|del)slice__ methods are deprecated since 2.0, but
for compatibility the built-in types must keep defining them. You may
want to override them as well if your class inherit from such a type.

With python 3.0 the __getslice__ slots were removed, and __getitem__ is
called in all cases.
History
Date User Action Args
2008-07-27 21:17:57amaury.forgeotdarcsetstatus: open -> closed
resolution: wont fix
messages: + msg70329
nosy: + amaury.forgeotdarc
2008-07-27 19:58:01johnfcreate