optimization question

Fredrik Lundh fredrik at pythonware.com
Mon Aug 12 23:16:43 CEST 2002


Terry Reedy wrote:

> If seq is one of the standard, builtin, Python sequence types (string,
> tuple, list), you can count on seq[i:j] being a new, separate object.

really?

>>> i = 0
>>> j = 3
>>> seq = (1, 2, 3)
>>> seq[i:j] is seq
1
>>> seq = "123"
>>> seq[i:j] is seq
1
>>> seq = [1, 2, 3]
>>> seq[i:j] is seq
0

</F>





More information about the Python-list mailing list