optimization question

Bengt Richter bokr at oz.net
Mon Aug 12 19:09:54 EDT 2002


On Mon, 12 Aug 2002 16:54:05 -0400, "Steve Holden" <sholden at holdenweb.com> wrote:

>"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" :-)
>
Why not? I hope the language is in the abstract semantics, not the implementation ;-)

Regards,
Bengt Richter



More information about the Python-list mailing list