[Python-ideas] Slicing and Chainging iterables.

Devin Jeanpierre jeanpierreda at gmail.com
Sun Jan 4 08:45:16 CET 2015


On Sat, Jan 3, 2015 at 11:23 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On 4 January 2015 at 07:14, Andrew Barnert
> <abarnert at yahoo.com.dmarc.invalid> wrote:
>> But it would be a pretty major change to
>> Python to move from iterators to views. And iterators are much simpler to create than views, so the tradeoff probably wouldn't be worth it, even if it weren't for the historical/compatibility issue. (It's much the same with Haskell-style lazy lists; Python iterables can only substitute for lazy lists 90% of the time, but that doesn't mean lazy lists are a better language choice.)
>
> It's worth noting that many types implement
> Mapping.(keys,values,items) as iterators in Python 3 rather than as
> views, and generally don't receive any complaints from users.

They probably should implement keys/etc. properly.
collections.abc.[Mutable]Mapping make it easy to support views if you
otherwise implement a dictionary-like object.

-- Devin


More information about the Python-ideas mailing list