optimization question

Terry Reedy tjreedy at udel.edu
Tue Aug 13 00:00:51 CEST 2002


"Fredrik Lundh" <fredrik at pythonware.com> wrote in message
news:%AV59.3825$HY3.1088150 at newsc.telia.net...
> 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

Ok, add: if it is a proper subsequence (which was the context of the
discussion) (or have I missed something else?)

TJR





More information about the Python-list mailing list