-
-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix equality check when other contains more keys #124
Conversation
Codecov Report
@@ Coverage Diff @@
## master #124 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 2 2
Lines 300 302 +2
=====================================
+ Hits 300 302 +2
Continue to review full report at Codecov.
|
multidict/_multidict_py.py
Outdated
@@ -120,6 +120,8 @@ def __eq__(self, other): | |||
if i1 != i2 or v1 != v2: | |||
return False | |||
return True | |||
if len(self) != len(other): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It must be possible to move this to before line 114
and remove check at line 117
. They are equal, so no need to have it copy-pasted in two places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree.
Check from line 117 is faster than line 123: no python magic method __len__
is involved.
Code duplication is very low, let's merge PR as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's about speed, then I'd convert len(self)
into len(self._impl._items)
done |
Test shows the issue.
Only Python version is affected.
P.S. I can not come up with more test cases, so I'm not sure that fix is final