Uh oh!
There was an error while loading. Please reload this page.
gh-112069: Adapt set/frozenset methods to Argument Clinic - #115112
Conversation
tomasr8
commented
Feb 6, 2024
@erlend-aasland Is there a way to convert the number functions (like |
erlend-aasland
commented
Feb 7, 2024
You can only adapt |
erlend-aasland
commented
Feb 7, 2024
See #114258 for clinic support for slots. |
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: AN Long <aisk@users.noreply.github.com>
tomasr8
commented
Feb 7, 2024
Thanks for the context! So if I understand correctly some of the |
erlend-aasland
commented
Feb 7, 2024
Anytime :)
That's the plan, yes.
We can adapt the slots later. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
erlend-aasland
commented
Feb 8, 2024
@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 <erlend.aasland@protonmail.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
erlend-aasland
commented
Feb 8, 2024
The Details--- 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. |
erlend-aasland
commented
Feb 8, 2024
BTW, generated clinic code excluded, the diff is now |
erlend-aasland
left a comment
There was a problem hiding this comment.
Thanks! (I'll land this after you've run make regen-clinic)
tomasr8
commented
Feb 8, 2024
Thanks a lot for your help! |
colesbury
commented
Feb 8, 2024
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) ```
…arargs (python#126064) Avoid temporary tuple creation when all arguments either positional-only or vararg. Objects/setobject.c and Modules/gcmodule.c adapted. This fixes slight performance regression for set methods, introduced by pythongh-115112.
…arargs (python#126064) Avoid temporary tuple creation when all arguments either positional-only or vararg. Objects/setobject.c and Modules/gcmodule.c adapted. This fixes slight performance regression for set methods, introduced by pythongh-115112.
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.
setthread-safe in--disable-gilbuilds #112069