On Sat, May 9, 2020 at 1:58 PM Alex Hall <alex.moj...@gmail.com> wrote:

>
> https://github.com/PythonCHB/islice-pep/blob/master/pep-xxx-islice.rst
>>
>> And the prototype implementation:
>>
>> https://github.com/PythonCHB/islice-pep/blob/master/islice.py
>>
>
>  I think this is a good idea. For sequences I'm not sure how big the
> benefit is - I get that it's more efficient, but I rarely care that much,
> because most lists are small. Why not extend the proposal to all iterators,
> or at least common ones like generators? That would allow avoiding
> itertools when I have no other choice.
>

I'm still confused what you mean by extend to all iterators? you mean that
you could use slice syntax with anything iterable>

And where does this fit in to the iterable vs iterator continuum?

iterables will return an iterator when iter() is called on them. So are you
suggesting that another way to get an iterator from an iterable would be to
pass a slice somehow that would return an iterator off that slice?

so:

for i in an_iterable(a:b:c):
    ...

would work for any iterable? and use an iterator that would iterate as
specified by the slice?

That is kind of cool.

Though it is heading in a different direction that where Andrew was
proposing, that this would be about making and using views on sequences,
which really wouldn't make sense for any iterator.

And, of course, adding syntax is a heavier lift (though extending a major
built in protocol is not a small lift by any means)

-CHB

-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/JCFTPY7U2T3QZGWRG7K4LOJ3XBIYRVZZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to