On May 14, 2020, at 10:45, Rhodri James <rho...@kynesim.co.uk> wrote: > > On 14/05/2020 17:47, Andrew Barnert via Python-ideas wrote: >> Which is exactly why Christopher said from the start of this thread, >> and everyone else has agreed at every step of the way, that we can’t >> change the default behavior of slicing, we have to instead add some >> new way to specifically ask for something different. > > Erm, did someone actually ask for something different? As far as I can tell > the original thread OP was asking for islice-maker objects, which don't > require the behaviour of slicing to change at all. Quite where the demand > for slice views has come from I'm not at all clear.
That doesn’t make any difference here. If you want slicing sequences to return iterators rather than copies, that would break way too much code, so it’s not going to happen. A different method/property/class/function that gives you iterators would be fine. If you want slicing sequences to return views rather than copies, that would break way too much code, so it’s not going to happen. A different method/property/class/function that gives you iterators would be fine. Which is why nobody has proposed changing what list.__getitem__, etc. will do. As for where views came from: because they do everything iterators do plus things they don’t, and in this case they’re about as easy to implement. It’s really the same thing as dict.items. People wanted a dict.items that didn’t copy the whole thing into a giant list. The first suggestion was for an iterator. But that would break too much code, so it couldn’t be done until 3.0. But it was still so useful that it was worth having before 3.x, so it was added to 2.6 with a distinct name, iteritems. But then people realized they could have a view just as easily as an iterator, and it would do more, so that’s what actually went into 3.0. And that turned out to be so useful that it was worth having before 3.x, so, even though iteritems had already been added in 2.6, it was phased out for viewitems in 2.7. I’m just trying to jump to the end here. Some of the issues aren’t the same (should it be a function or an attribute, is it worth having custom implementations for some builtin types, …), but some of them are, so we can learn from the past instead of repeating the same process. We can just build the equivalent of viewitems right off the bat, and not even think about changing plain slicing (because we never want another 3.0 break). (Of course there may still be good arguments for why this isn’t the same, or for why it should end up differently even if it _is_ the same.) _______________________________________________ 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/TLTTZXWFP3QM6WRKEGF246RK6WYJSEG7/ Code of Conduct: http://python.org/psf/codeofconduct/