Final state of underlying sequence in islice

Shashank Singh shashank.sunny.singh at gmail.com
Sat Nov 6 02:43:21 EDT 2010


I have created an issue in roundup at http://bugs.python.org/issue10323.
I was expecting the discussion to move to that place but since it has not,
for the sake of completion I am quoting my response
to Raymond that I had posted on roundup.

> @Raymond: I don't have a particular use case where I had a problem with this behavior. I came across this "problem" when looking at this issue http://bugs.python.org/issue6305.
>
> An important problem that can happen with this behavior is that it does extra work that is not needed. Consider the case (it appears in Lib/test/test_itertools.py <http://svn.python.org/view/python/branches/py3k/Lib/test/test_itertools.py>):
>
> islice(count(), 1, 10, maxsize)
>
> where maxsize is MAX_Py_ssize_t
>
> Current implementation goes all the way up to maxsize when it should have just stopped at 10.
>
> You are probably right in saying that the caller can make sure that the parameters are such that such cases don't arise but I would still like to see python doing the best possible thing as far as possible.
>
>
-- 
Regards
Shashank Singh
shashank.sunny.singh at gmail.com
http://www.cse.iitb.ac.in/~shashanksingh<http://www.cse.iitb.ac.in/%7Eshashanksingh>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101106/a4dafdf8/attachment.html>


More information about the Python-list mailing list