[Python-bugs-list] [ python-Bugs-643115 ] Creating sets from dictionaries

noreply@sourceforge.net noreply@sourceforge.net
Mon, 25 Nov 2002 00:01:55 -0800


Bugs item #643115, was opened at 2002-11-24 10:54
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=643115&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Martin v. L÷wis (loewis)
>Assigned to: Guido van Rossum (gvanrossum)
Summary: Creating sets from dictionaries

Initial Comment:
When creating a set from a dictionary, the dictionary
values must not be copied. The following expression
gives, False, but should give True, since both sets
contain the same elements.

>>> from sets import Set
>>> Set({10:10}) == Set([10])
False


----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2002-11-25 03:01

Message:
Logged In: YES 
user_id=80475

Guido, do you have a preference?

BTW, the reasons for my preferring to revise the equality 
tests are:
1.  It's much easier to verify that a revised equality test 
compares only keys than it is to permanently preclude all 
possible ways a foreign value could sneak in.
2.  I would rather slow down an equality test than lose the 
speed of converting a dict to a set (which can occur either 
externalor internal to the module).

----------------------------------------------------------------------

Comment By: Martin v. L÷wis (loewis)
Date: 2002-11-25 02:47

Message:
Logged In: YES 
user_id=21627

I'd be fine with either approach.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2002-11-24 23:02

Message:
Logged In: YES 
user_id=80475

There are two ways to go with this one.  Either follow the 
OP suggestion and force all values to be True, or revise the 
equality tests to only compare keys.

I like the second approach but am posting patches for 
both.  If one or the other is approved, will add the failure 
to the test_suite.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=643115&group_id=5470