Chris Angelico wrote: > On Mon, 20 Jun 2022 at 21:11, Mathew Elman mathew.el...@ocado.com wrote: > > This I like - it seems very intuitive, almost like an irreversible io > > stream. > > I don't know if there would be cases where this would lead to unexpected > > bugs, but without looking into it it seems nice. > > Question: What would be the natural behaviour for negative indices? Raising > > an error? > > Please quote the person and text that you're responding to (and then > add your response underneath). Otherwise we have to guess which > (sub)proposal it is that you like. > ChrisA
Oops, I thought I had, it was this: > To me, the natural implementation of slicing on a non-reusable iterator (such > as a generator) would be that you are not allowed to go backwards or even > stand still: > mygen[42] > mygen[42] > ValueError: Element 42 of iterator has already been used (Apologies if I > don't know the difference between an iterator and an iterable; y'all know > what I mean.) > You still get a useful feature that you didn't have before. Expecting a > generator (or whatever) to cache some its values in case you wanted a slice > of them opens up a huge can of worms and is surely best forgotten. (100Gb > generator anyone?) Well, maybe caching ONE value (the last one accessed) is > reasonable, so you could stand still but not go backwards. But it's still > adding overhead. > Best wishes > Rob Cliffe _______________________________________________ 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/LL5FBAT53QJRKGLQEY3H3GD6JGXTB4QE/ Code of Conduct: http://python.org/psf/codeofconduct/