Antoine Pitrou wrote: > On Sun, 16 May 2010 11:55:14 +1000 > Yaniv Aknin <ya...@aknin.name> wrote: >> Is the whole notion of a frozendict >> worthy, given this limitation? > > I don't think so. Of course we how have a more general problem: > - if we choose to implement only equality testing for partials and > leave hashing as is, then hashing isn't consistent with equality > anymore -- which is unacceptable > - if we choose to implement only equality testing for partials and make > them unhashable, we are breaking programs which store partials in a > set or a dict > > So we are left with the following choice: > - implement hashing consistently with equality testing, even though the > keyword arguments can be changed later. I think this is acceptable > from a practicality standpoint
Another option is to compare the keywords by identity rather than value. This is likely to be more correct anyway, since items may compare equal without giving the same result for all functions: >>> dict(a=1) == dict(a=1.0) True >>> partial(type, 1)() <type 'int'> >>> partial(type, 1.0)() <type 'float'> Once you're comparing the supplied arguments by identity rather than value, the question of hashability goes away. Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia --------------------------------------------------------------- _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com