Specify start and length, beside start and end, in slices

Peter Hansen peter at engcorp.com
Fri May 21 11:40:42 EDT 2004


Noam Raphael wrote:

> Grant Edwards wrote:
>> It's a bit less efficient, but you can currently spell that as
>>
>> l[12345:][:10]
>>
> That is true, but if the list is long, it's *much* less efficient.

Considering that the interpreter special-cases some integer math
including the BINARY_ADD, it likely wouldn't take a very long list
to pass the point where they're the same.

I like the idea of the optimization, in a sense, but I don't
like the syntax and doubt that there is much performance gain to be
had.  There are probably better places for people to hack on the
interpreter, and which don't need syntax changes.

-Peter



More information about the Python-list mailing list