This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mgiuca
Recipients erickt, mgiuca
Date 2008-08-16.10:59:00
SpamBayes Score 7.9526853e-07
Marked as misclassified No
Message-id <1218884342.08.0.77112069093.issue3564@psf.upfronthosting.co.za>
In-reply-to
Content
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
(undecidable) to get pure equality of higher order values (functions) in
a programming language (because strictly, any two functions which give
the same results for the same input are equal, but it's undecidable
whether any two functions will give the same results for all inputs). So
we have to be conservative (false negatives, but no false positives).

In other words, should these compare equal?

>>> (lambda x: x + 1) == (lambda x: x + 1)
False (even though technically they describe the same function)

I would argue that if you call functools.partial twice, separately, then
you are creating two function objects which are not equal.

I would also argue that functools.partial(f, arg1, ..., argn) should be
equivalent to lambda *rest: f(arg1, ..., argn, *rest). Hence your example:
>>> def foo(): pass
>>> f1=functools.partial(foo)
>>> f2=functools.partial(foo)

Is basically equivalent to doing this:

>>> def foo(): pass
>>> f1 = lambda: foo()
>>> f2 = lambda: foo()

Now f1 and f2 are not equal, because they are two separately defined
functions.

I think you should raise this on Python-ideas, instead of as a bug report:
http://mail.python.org/pipermail/python-ideas/

But with two identical functions comparing INEQUAL if they were created
separately, I see no reason for partial functions to behave differently.
History
Date User Action Args
2008-08-16 10:59:02mgiucasetrecipients: + mgiuca, erickt
2008-08-16 10:59:02mgiucasetmessageid: <1218884342.08.0.77112069093.issue3564@psf.upfronthosting.co.za>
2008-08-16 10:59:01mgiucalinkissue3564 messages
2008-08-16 10:59:00mgiucacreate