On Mon, May 11, 2020 at 11:38 AM Andrew Barnert <abarnert@yahoo.com> wrote:
On May 11, 2020, at 10:57, Alex Hall <alex.mojaki@gmail.com> wrote:

On Mon, May 11, 2020 at 12:50 AM Christopher Barker <pythonchb@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:


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.


Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython