classification
Title: Convert complex methods to Argument Clinic
Type: performance Stage: resolved
Components: Argument Clinic Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: corona10 Nosy List: corona10, larry, mark.dickinson, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2020-07-19 14:49 by corona10, last changed 2020-07-20 12:56 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 21550 merged corona10, 2020-07-19 14:56
Messages (5)
msg373966 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2020-07-19 14:49
Mean +- std dev: [master_format] 3.54 us +- 0.06 us -> [clinic_format] 3.29 us +- 0.07 us: 1.08x faster (-7%)

Mean +- std dev: [master_conjugate] 3.56 us +- 0.09 us -> [clinic_conjugate] 3.32 us +- 0.06 us: 1.07x faster (-7%)

Mean +- std dev: [master__getnewargs__] 425 ns +- 18 ns -> [clinic__getnewargs__] 412 ns +- 7 ns: 1.03x faster (-3%)
msg373968 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-07-19 15:51
I wrote similar patch for __format__ and got similar tiny speed up. It is expectable. But I am surprised that you get a difference for conjugate() and __getnewargs__. It may be a compiler artifact.

In any case the benefit of converting to Argument Clinic in this case is adding signatures for these methods.
msg373983 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2020-07-20 05:43
> But I am surprised that you get a difference for conjugate() and __getnewargs__. 

It could be a noise :)
msg373984 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2020-07-20 05:47
Hmm, I re-ran all the benchmark.
- conjugate => It looks like noise. 
- __getnewargs__ -> consistently showing performance improvement. (2-3%)

FYI, I ran benchmarks on the macOS.
msg374002 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-07-20 12:53
New changeset e123012d79121ab543583631bb84c7fc27d06338 by Dong-hee Na in branch 'master':
bpo-41343: Convert methods of complex to Argument Clinic (GH-21550)
https://github.com/python/cpython/commit/e123012d79121ab543583631bb84c7fc27d06338
History
Date User Action Args
2020-07-20 12:56:58serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-07-20 12:53:32serhiy.storchakasetmessages: + msg374002
2020-07-20 05:47:37corona10setmessages: + msg373984
2020-07-20 05:43:43corona10setmessages: + msg373983
2020-07-19 15:51:36serhiy.storchakasetnosy: + mark.dickinson, serhiy.storchaka
messages: + msg373968
2020-07-19 14:56:07corona10setkeywords: + patch
stage: patch review
pull_requests: + pull_request20692
2020-07-19 14:50:25corona10setassignee: corona10
2020-07-19 14:49:49corona10create