[issue3564] making partial functions comparable

Antoine Pitrou report at bugs.python.org
Sat Aug 16 18:32:54 CEST 2008


Antoine Pitrou <pitrou at free.fr> added the comment:

I would add that making the comparison "right" for partial would be
trickier than it seems:

>>> from functools import partial
>>> type == type
True
>>> 1 == 1.0
True
>>> partial(type, 1)() == partial(type, 1.0)()
False

If partial(type, 1) and partial(type, 1.0) were to compare equal, it
would break the expectation, stated by Matt, that two equal function
objects produce the same results when given the same inputs.


PS: 
>>> partial(type, 1)()
<type 'int'>
>>> partial(type, 1.0)()
<type 'float'>

----------
nosy: +pitrou

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


More information about the Python-bugs-list mailing list