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

Noam Raphael noamr at correctme.users.sourcephorge.net
Fri May 21 11:55:22 EDT 2004


Peter Hansen wrote:
> 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 don't understand: If the list is of length 1000000, wouldn't Grant 
Edwards' suggestion make 1000000-12345 new references, and then take 
only the first ten of them?



More information about the Python-list mailing list