Skip to content

bpo-37207: Use PEP 590 vectorcall to speed up frozenset() - #19053

Merged
vstinner merged 7 commits into
python:masterfrom
corona10:bpo-37207-frozenset
Mar 18, 2020
Merged

bpo-37207: Use PEP 590 vectorcall to speed up frozenset()#19053
vstinner merged 7 commits into
python:masterfrom
corona10:bpo-37207-frozenset

Conversation

@corona10

@corona10 corona10 commented Mar 18, 2020

Copy link
Copy Markdown
Member
Mean +- std dev: [master] 2.26 us +- 0.06 us -> [pr] 2.06 us +- 0.05 us: 1.09x faster (-9%) 

https://bugs.python.org/issue37207

@corona10

corona10 commented Mar 18, 2020

Copy link
Copy Markdown
Member Author

The benchmark from the https://bugs.python.org/issue37207#msg364428 was executed by below script.

import pyperf

runner = pyperf.Runner()
runner.timeit(name="frozenset create test",
              stmt="frozenset([1, 2, 3, 4, 5])")
Comment thread Objects/setobject.c Outdated
@corona10
corona10 force-pushed the bpo-37207-frozenset branch from 6ae0f81 to 27db91d Compare March 18, 2020 14:26
@corona10 corona10 changed the title bpo-37207: Use PEP 590 vectorcall to speed up frozenset() Mar 18, 2020
@corona10 corona10 changed the title [WIP] bpo-37207: Use PEP 590 vectorcall to speed up frozenset() Mar 18, 2020
@corona10
corona10 requested a review from vstinner March 18, 2020 14:47
@corona10

Copy link
Copy Markdown
Member Author

@vstinner

Updated, During I work on helper function, I updated my git client and
during this process, it makes duplicated commits 27db91d d467294 .
I resolved all confliction and now it works okay. I also checked reference leak
through ./python.exe -m test test_set -R 3:3and there was no leak ;-)

@corona10

Copy link
Copy Markdown
Member Author

And performance improvement is still valid.

Mean +- std dev: [master] 2.30 us +- 0.10 us -> [pr] 2.10 us +- 0.06 us: 1.10x faster (-9%)
Comment thread Objects/setobject.c
Comment thread Objects/setobject.c Outdated
Comment thread Objects/setobject.c Outdated
Comment thread Objects/setobject.c Outdated
Comment thread Objects/setobject.c Outdated
Comment thread Objects/setobject.c Outdated
Comment thread Objects/setobject.c Outdated
@corona10
corona10 requested a review from vstinner March 18, 2020 16:38
@vstinner
vstinner merged commit 1c60567 into python:master Mar 18, 2020
@vstinner

Copy link
Copy Markdown
Member

Thanks @corona10: 1.09x faster (-9%) is nice to have (-200 ns). And IMHO the change makes the code more readable with new comments.

@corona10
corona10 deleted the bpo-37207-frozenset branch March 18, 2020 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants