-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
py/objset: Allow intersection() to take multiple sets as args. #15818
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #15818 +/- ##
=======================================
Coverage 98.43% 98.43%
=======================================
Files 163 163
Lines 21294 21296 +2
=======================================
+ Hits 20960 20962 +2
Misses 334 334 ☔ View full report in Codecov by Sentry. |
Code size report:
|
ad19a10
to
5d2e79b
Compare
I've modified the |
Signed-off-by: Amirreza Hamzavi <[email protected]>
5d2e79b
to
a71e394
Compare
I've also set minimum accepted arg count to 1 in order to make |
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.
This looks good to me, the code size is similar to the current version and the temporary memory usage looks like it won't be significantly worse than calling the single argument version multiple times in a row.
It seems a little bit more code is needed to avoid unnecessary copy when |
I think it's worth improving things so it doesn't need the unnecessary copy. The new implementation should match the existing implementation (in terms of memory usage) for And fixing that will actual improve the general case for Please try to do that, and we'll see how much firmware size changes. It shouldn't be too bad. |
@@ -1,7 +1,21 @@ | |||
s = {1, 2, 3, 4} | |||
print(sorted(s)) | |||
print(sorted(s.intersection())) | |||
print(sorted(s)) |
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.
Needs an additional test to ensure that s.intersection()
is a copy of s
.
CPython allows
set.intersection()
to take multiple iterables as arguments and It seemsCPython 2.6
implemented this mechanism. Micropython currently allows only one iterable as argument and this PR aims to increase compatibility with CPython.