Terry J. Reedy <[EMAIL PROTECTED]> added the comment:
The default equality comparison of Python objects is by id.
Some classes override this, others, in particular, functions, do not.
I also agree that partial functions should not either.
However, you can subclass functools.partial (I checked in
Antoine Pitrou <[EMAIL PROTECTED]> 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) an
Matt Giuca <[EMAIL PROTECTED]> added the comment:
It's highly debatable whether these should compare true. (Note: saying
"they aren't comparable" is a misnomer -- they are comparable, they just
don't compare equal).
>From a mathematical standpoint, they *are* equal, but it's impossible
(undecida
New submission from Erick Tryzelaar <[EMAIL PROTECTED]>:
functools.partial functions are not comparable, in both python 2.5 and
3.0:
>>> def foo(): pass
>>> functools.partial(foo) == functools.partial(foo)
False
It can be worked around by comparing the func, args, and keywords, but
this means