[Python-3000] Spooky behavior of dict.items() and friends

Jason Orendorff jason.orendorff at gmail.com
Thu Apr 3 00:33:26 CEST 2008


On Wed, Apr 2, 2008 at 5:08 PM, Mike Klaas <mike.klaas at gmail.com> wrote:
>  ...and the majority of these cases would work fine with views (input
>  to sorted(), etc).

Suppose "the majority" here means 36 of the 46 cases.  Then what
you're saying is, if I write .items() without thinking, there's about
a 3% chance it won't work (10 out of 339 cases).  Forgive me:  the
fact that you've gotten it down to 3%, e.g. by making items() return a
view instead of an iterator, doesn't make me terrifically happy.

I'm OK with the status quo.  Maybe iteritems() is a wart, but I think
views will be a much worse wart!

If the only hard requirement is that dict lose *something* in Python
3.0, I suggest droping values() and itervalues(), as I never use them.
 ;-)

-j


More information about the Python-3000 mailing list