-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
gh-112069: Adapt set/frozenset methods to Argument Clinic #115112
gh-112069: Adapt set/frozenset methods to Argument Clinic #115112
Conversation
@erlend-aasland Is there a way to convert the number functions (like |
You can only adapt |
See #114258 for clinic support for slots. |
Misc/NEWS.d/next/Core and Builtins/2024-02-07-00-18-42.gh-issue-112069.jRDRR5.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: AN Long <[email protected]>
Thanks for the context! So if I understand correctly some of the |
Anytime :)
That's the plan, yes.
We can adapt the slots later. |
@tomasr8, I marked this as a draft while you are working on updating it; mark is as ready for review when you are ready for a new round of reviews. |
Co-authored-by: Erlend E. Aasland <[email protected]>
Misc/NEWS.d/next/Core and Builtins/2024-02-07-00-18-42.gh-issue-112069.jRDRR5.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: Erlend E. Aasland <[email protected]>
The --- main.txt 2024-02-08 16:23:15
+++ pr.txt 2024-02-08 16:23:38
@@ -77,7 +77,7 @@
| Return value^self.
|
| __sizeof__(self, /)
- | S.__sizeof__() -> size of S in memory, in bytes
+ | S.__sizeof__() -> size of S in memory, in bytes.
|
| __sub__(self, value, /)
| Return self-value.
@@ -114,17 +114,18 @@
| intersection_update(self, /, *others)
| Update the set, keeping only elements found in it and all others.
|
- | isdisjoint(self, object, /)
+ | isdisjoint(self, other, /)
| Return True if two sets have a null intersection.
|
- | issubset(self, object, /)
+ | issubset(self, other, /)
| Report whether another set contains this set.
|
- | issuperset(self, object, /)
+ | issuperset(self, other, /)
| Report whether this set contains another set.
|
| pop(self, /)
| Remove and return an arbitrary set element.
+ |
| Raises KeyError if the set is empty.
|
| remove(self, object, /)
@@ -228,7 +229,7 @@
| Return value^self.
|
| __sizeof__(self, /)
- | S.__sizeof__() -> size of S in memory, in bytes
+ | S.__sizeof__() -> size of S in memory, in bytes.
|
| __sub__(self, value, /)
| Return self-value.
@@ -245,13 +246,13 @@
| intersection(self, /, *others)
| Return a new set with elements common to the set and all others.
|
- | isdisjoint(self, object, /)
+ | isdisjoint(self, other, /)
| Return True if two sets have a null intersection.
|
- | issubset(self, object, /)
+ | issubset(self, other, /)
| Report whether another set contains this set.
|
- | issuperset(self, object, /)
+ | issuperset(self, other, /)
| Report whether this set contains another set.
|
| symmetric_difference(self, other, /) There's one case of an added punctuation, and a couple of cases where the new docstring now aligns better with the docs (using other iso. object). IMO, this is acceptable. |
BTW, generated clinic code excluded, the diff is now |
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.
Thanks! (I'll land this after you've run make regen-clinic
)
Thanks a lot for your help! |
Thanks @tomasr8 and @erlend-aasland! |
Current patch partially address issue, working in case when all arguments either positional-only or vararg. This also converts gcd(), lcm() and hypot() functions of the math module to the Argument Clinic. Fix issue python#101123. Objects/setobject.c and Modules/gcmodule.c adapted. This fixes slight performance regression for set methods, introduced by python#115112: | Benchmark | ref | patch | |----------------------|:------:|:--------------------:| | set().update(s1, s2) | 354 ns | 264 ns: 1.34x faster | Benchmark code: ```py import pyperf s1, s2 = {1}, {2} runner = pyperf.Runner() runner.bench_func('set().update(s1, s2)', set().update, s1, s2) ```
This is the first to step to making the set object thread-safe in free threading Python. See this PR for reference. As suggested, I am splitting the PR into one which first adds AC support and then a followup PR which adds thread safety.
set
thread-safe in--disable-gil
builds #112069