Message 267236 - Python tracker

Message267236

Author alex0307
Recipients alex0307, docs@python
Date 2016-06-04.05:33:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1465018426.98.0.63725897135.issue27212@psf.upfronthosting.co.za>
In-reply-to
Content
In the doc for itertools, the python implementation of islice() doesn't actually perform the iteration when given an empty slice (e.g. islice(it,3,3)). 

This is not the expected behavior for 'consume()' in the recipe given below, i.e. consume(it,3) couldn't actually advance the iterator for 3 steps ahead. Instead, the iterator stays at its starting position.

As a simple fix, in the implementation of islice(), the length of the slice object should be checked first. If it's zero, the iterator should be advanced (slice.start-1) times, and return (See islice_my.py)
History
Date User Action Args
2016-06-04 05:33:47alex0307setrecipients: + alex0307, docs@python
2016-06-04 05:33:46alex0307setmessageid: <1465018426.98.0.63725897135.issue27212@psf.upfronthosting.co.za>
2016-06-04 05:33:46alex0307linkissue27212 messages
2016-06-04 05:33:46alex0307create