Message225343
The hash function of the Signature class is actually incompatible with the definition of Signature equality, which doesn't consider the order of keyword-only arguments:
>>> from inspect import signature
>>> s1 = signature(lambda *, x, y: None); s2 = signature(lambda *, y, x: None)
>>> s1 == s2
True
>>> hash(s1) == hash(s2)
False
Actually the implementation of Signature.__eq__ seems way too complicated; I would suggest making a helper method returning (return_annotation, tuple(non-kw-only-params), frozenset(kw-only-params)) so that __eq__ can compare these values while __hash__ can hash that tuple. |
|
Date |
User |
Action |
Args |
2014-08-15 06:01:40 | Antony.Lee | set | recipients:
+ Antony.Lee, brett.cannon, ncoghlan, larry, python-dev, yselivanov |
2014-08-15 06:01:40 | Antony.Lee | set | messageid: <1408082500.66.0.213200245911.issue20334@psf.upfronthosting.co.za> |
2014-08-15 06:01:40 | Antony.Lee | link | issue20334 messages |
2014-08-15 06:01:40 | Antony.Lee | create | |
|