A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-March/062787.html below:

[Python-Dev] [Python-3000] Iterators for dict keys, values, and items == annoying :)

[Python-Dev] [Python-3000] Iterators for dict keys, values, and items == annoying :)Nick Coghlan ncoghlan at gmail.com
Fri Mar 24 11:15:32 CET 2006
Greg Ewing wrote:
> Guido van Rossum wrote:
> 
>> Its maps have methods to
>> return keys, values and items, but these return neither new lists nor
>> iterators; they return "views" which obey set (or multiset, in the
>> case of items) semantics.
> 
>> I'd like to explore this as an alternative to making keys() etc.
>> return iterators.
> 
> This sounds like a really really good idea!
> 
> It would solve Jim's problem, because the result of
> d.keys() would print out just like a real list, and
> then he could backspace over the .keys() and do
> something else.

If these things returned iterables rather than actual iterators (i.e. similar 
to what xrange currently does), it would also address the fact that caching 
references to iterators just doesn't work.

For example:

   keys = d.keys()
   big_key = max(keys)
   little_key = max(keys)

If keys() returns a list or other iterable, all is good. If it returns an 
actual iterator though. . .

I do find it somewhat interesting that we're considering moving the standard 
containers to a more numpy-ish view of the world, though (i.e. one where 
multiple mutable views of a data structure are common in order to avoid 
unnecessary copying)

Would that philosophy be extended to slicing operations, though?

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4