[Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation (original) (raw)
Travis E. Oliphant oliphant.travis at ieee.org
Thu Feb 9 22:39:07 CET 2006
- Previous message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Next message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Bengt Richter wrote:
How about if SLICE byte code interpretation would try to call obj.int() if passed a non-(int,long) obj ? Would that cover your use case?
I believe that this is pretty much exactly what I'm proposing. The apply_slice and assign_slice functions in ceval.c are called for the SLICE and STORE_SLICE and DELETE_SLICE opcodes.
BTW the slice type happily accepts anything for start:stop:step I believe, and something[slice(whatever)] will call something.getitem with the slice instance, though this is neither a fast nor nicely spelled way to customize.
Yes, the slice object itself takes whatever you want. However, Python special-cases what happens for X[a:b] if X as the sequence-protocol defined. This is the code-path I'm trying to enhance.
-Travis
- Previous message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Next message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]