optimization question

Steve Holden sholden at holdenweb.com
Mon Aug 12 22:54:05 CEST 2002


"Andrew Koenig" <ark at research.att.com> wrote in message
news:yu99d6snaktm.fsf at europa.research.att.com...
> Terry> If seq is one of the standard, builtin, Python sequence types
> Terry> (string, tuple, list), you can count on seq[i:j] being a new,
> Terry> separate object.  That is part of the language definition.  In
> Terry> the context of comparisons, you can count on it *not* being
> Terry> optimized - it is not a possibility.
>
> Surely "not a possibility" is too strong -- if seq[i:j] is an
> immutable sequence, the implementation could optimize the
> slice if it wanted to do so.
>

Yes, it could. It could then, however, hardly be called "one of the
standard, builtin, Python sequence types" :-)

regards
-----------------------------------------------------------------------
Steve Holden                                 http://www.holdenweb.com/
Python Web Programming                http://pydish.holdenweb.com/pwp/
-----------------------------------------------------------------------








More information about the Python-list mailing list