A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2006-March/063230.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 :)Taro Ogawa taroso at gmail.com
Fri Mar 31 06:23:43 CEST 2006
Nick Coghlan <ncoghlan <at> gmail.com> writes:
> There are three big use cases:
>    dict.keys
>    dict.values
>    dict.items
> Currently these all return lists, which may be expensive in terms of copying.
> They all have iter* variants which while memory efficient, are far less 
> convenient to work with.
<delurk>
Is there any reason why they can't be view objects - a dictionary has keys, 
has values, has items - rather than methods returning view objects:
    for k in mydict.keys:
        ...
    for v in mydict.values:
        ...
    for k, v in mydict.items:
        ...
For backward compatibility with Py2.x, calling them would raise a 
DeprecationWarning and return a list.  This could even be introduced in 2.x 
(with a PendingDeprecationWarning instead?).

Cheers, -T.

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