[Python-3000] Iterators for dict keys, values, and items == annoying :)
Adam DePrince
adam.deprince at gmail.com
Sat Apr 1 05:03:39 CEST 2006
On Fri, 2006-03-31 at 07:44 +1000, Nick Coghlan wrote:
> Adam DePrince wrote:
> > There seemed to be a concensus in the community on the size of the view
> > proposal, and I'm reimplementing the PEP to reflect that. But what I
> > can't resolve is the other anciliary issue: "To list or iter." I'm not
> > yet ready to resolve that issue. The views don't resolve it either, and
> > by their nature are biased towards the iter approach. They provide
> > __iter__ because its light weight to do, but there is no way a light
> > weight view can provide you with ordering information from an unordered
> > datastore. Now, as a means of resolving this conflict, I'm open to the
> > notion of a view implementing both __iter__ and an explicit .list method
> > to avoid any extra overhead in generating a list from an iter instead of
> > directly from the dict as we do now.
>
> Umm, the whole point of the views discussion is the realisation that "list or
> iterator" is a false dichotomy. The correct answer is "new iterable that looks
The false dichotomy is not of my construction; some of the objections
that I've received have been of the form:
"""When I say
>>>print dict.items()
with views instead of iters it still won't look like a list! """
Until that debate is resolved it will still taint discussion of any
non-lists that dict.items/values might return.
- Adam
More information about the Python-3000
mailing list