Message267236
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) |
|
Date |
User |
Action |
Args |
2016-06-04 05:33:47 | alex0307 | set | recipients:
+ alex0307, docs@python |
2016-06-04 05:33:46 | alex0307 | set | messageid: <1465018426.98.0.63725897135.issue27212@psf.upfronthosting.co.za> |
2016-06-04 05:33:46 | alex0307 | link | issue27212 messages |
2016-06-04 05:33:46 | alex0307 | create | |
|