[Python-Dev] Possible patch for functools partial - Interested?

Steven D'Aprano steve at pearwood.info
Wed May 12 12:37:51 CEST 2010


On Wed, 12 May 2010 06:34:50 pm Stephen J. Turnbull wrote:
> Lie Ryan writes:
>  > it disappoints me this does not compare equal:
>  >
>  > add3 = lambda a, b, c: a + b + c
>  > a = partial(partial(add3, 1), 2)
>  > b = partial(partial(add3, 2), 1)
>  > print a == b
>  >
>  > :-)
>
> But it's not even true for floating point.<wink>


All humour aside, let's not ruin the chances of this patch being 
accepted by overloading it. I think there is a good use-case for 
partial objects to compare equal if they were constructed with 
arguments that compare equal. That's a nice, conservative change that 
is unlikely to lead to bugs, unlike some of the more "clever" proposals 
that rely on mathematical equivalences that don't hold for Python 
objects.



-- 
Steven D'Aprano


More information about the Python-Dev mailing list