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 what I'm proposing (except I'm not proposing to use the __int__ method because it is already used as coercion and doing this would allow floats to be used in slices which is a bad thing). 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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4