[Python-3000] PEP 3106: Revamping dict.keys(), .values() and .items()

Delaney, Timothy (Tim) tdelaney at avaya.com
Wed Dec 20 21:40:01 CET 2006

Talin wrote:

> 1) values() should be documented as list-like rather than set-like.
> (Or 
> better yet bag-like, but Python doesn't have bags. In other words,
> it's 
> really an unordered collection of items with no special indexing
> semantics or uniqueness constraint.)
> My reasoning is that generally people don't expect to be able to do
> set 
> membership tests of the values of a mapping; Mostly, values() is used
> for iteration. And given that all of the set-like operations are slow,
> let's just cut to the chase and say that values() isn't a set at all.

I almost agree here, but the property that multiset(1, 2, 2) ==
multiset(2, 1, 2) seems useful for a dict values view.

OTOH, how many people have complained that given d1 == d2, d1.values()
may not equal d2.values() in 2.x? I've definitely never had any problems
with it, but then again, I find it rare that I've needed values().

Tim Delaney

More information about the Python-3000 mailing list