optimization question

Brian Quinlan brian at sweetapp.com
Sun Aug 11 21:18:09 CEST 2002

Andrew Koenig wrote: 
> can I count on the implementation not to form s[i:j] as a new
> substring? 

You can't:

 0 SET_LINENO               1
 3 LOAD_GLOBAL              0 (s)
 6 LOAD_GLOBAL              1 (i)
 9 LOAD_GLOBAL              2 (j)
12 SLICE+3
13 LOAD_GLOBAL              3 (t)
16 COMPARE_OP               2 (==)

SLICE+3 implements TOS = TOS2[TOS1:TOS]

I started writing a lazy-slicing PEP/implementation once but the
implementation would have been hard to maintain and there would have
been backwards compatibility problems at the C API level.


More information about the Python-list mailing list