On Mon, May 11, 2020 at 11:38 AM Andrew Barnert <abarn...@yahoo.com> wrote:
> On May 11, 2020, at 10:57, Alex Hall <alex.moj...@gmail.com> wrote: > > > On Mon, May 11, 2020 at 12:50 AM Christopher Barker <python...@gmail.com> > wrote: > > >> 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. >> > > The idea is that islice would be the default behaviour and classes could > override that to return views if they want. > > I'm still confused about this -- islice returns an iterator that iterates over the passed-in iterable -- that is standard behvior for most tools in itertools. So I ca see that it would be nice to have a slice syntax that would work on all iterables, not just sequences, but I *think* that's a totally different idea. Anyway, thanks all for the input. When get a chance, I'll update my proposal with the input. I think I'll go for Andrew's idea of a sequence_view object -- that would give me my "lazy slice", and other nifty features. > But maybe doing it _just_ for view slicing, rather than for everything, and requiring a wrapper object to use it, is a lot simpler, and useful enough on its own. I'm not quite sure what a "view for slicing" means, but maybe it's what I'm thinking about. But I would describe what I'm thinking about is a view object that you can get with slicing syntax. There are two key parts here -- we *could* have just an iterator with slice syntax, and also a view without slice syntax, but Im all for getting them together. Again, I welcome PRs on my notes and prototpe code: https://github.com/PythonCHB/islice-pep I'd particularly welcome text about the motivation and use-cases for a sequence view object -- my text is all about only the iterating part. -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/BSRBJJHJ4VYV3T6TSNRWCYVVXMLOEJBT/ Code of Conduct: http://python.org/psf/codeofconduct/