Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51153 > unrolled thread
| Started by | Stefan Behnel <stefan_ml@behnel.de> |
|---|---|
| First post | 2013-07-24 19:23 +0200 |
| Last post | 2013-07-24 19:23 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Python 3: dict & dict.keys() Stefan Behnel <stefan_ml@behnel.de> - 2013-07-24 19:23 +0200
| From | Stefan Behnel <stefan_ml@behnel.de> |
|---|---|
| Date | 2013-07-24 19:23 +0200 |
| Subject | Re: Python 3: dict & dict.keys() |
| Message-ID | <mailman.5055.1374686640.3114.python-list@python.org> |
Peter Otten, 24.07.2013 08:23: > Ethan Furman wrote: >> So, my question boils down to: in Python 3 how is dict.keys() different >> from dict? What are the use cases? > > I just grepped through /usr/lib/python3, and could not identify a single > line where some_object.keys() wasn't either wrapped in a list (or set, > sorted, max) call, or iterated over. In case that directory mainly consists of the standard library, then you shouldn't forget that most of the code in there predates Python 3 by ages and was only adapted to work with the new syntax/semantics, not rewritten in a "better" way. Even if it's not just the stdlib, that argument still holds. There is still fairly little code out there that was specifically written for Py2.6+, as opposed to just being adapted. > To me it looks like views are a solution waiting for a problem. They reduce the API overhead. Previously, you needed values() and itervalues(), with values() being not more than a special case of what itervalues() provides anyway. Now it's just one method that gives you everything. It simply has corrected the tradeoff from two special purpose APIs to one general purpose API, that's all. Stefan
Back to top | Article view | comp.lang.python
csiph-web