[issue8752] set_contains, etc. should check for collections.Set in addition to PySet_Check

Daniel Stutzbach report at bugs.python.org
Tue May 18 17:21:12 CEST 2010


New submission from Daniel Stutzbach <daniel at stutzbachenterprises.com>:

For operations that test membership in a set, Python coerces sets and subclasses of set into a temporary frozenset before testing membership.

For example, this works:

>>> set() in set([frozenset()])
True

Although the set() is not hashable itself, Python creates a temporary frozenset() out of the set().  It should do the same for user-types derived from collections.Set, so they can inter-operate in the same way.

In setobject.c, the following methods behave in the described manner: set_contains, set_remove, and set_discard.

----------
components: Interpreter Core
messages: 105983
nosy: stutzbach
priority: normal
severity: normal
stage: unit test needed
status: open
title: set_contains, etc. should check for collections.Set in addition to PySet_Check
type: behavior
versions: Python 2.7, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8752>
_______________________________________


More information about the Python-bugs-list mailing list