8000 bpo-37207: Use PEP 590 vectorcall to speed up set() by corona10 · Pull Request #19019 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-37207: Use PEP 590 vectorcall to speed up set() #19019

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

Merged
merged 2 commits into from
Mar 16, 2020

Conversation

corona10
Copy link
Member
@corona10 corona10 commented Mar 15, 2020

PEP 590

./python.exe -m pyperf timeit "set([1, 2, 3, 4, 5])"
.....................
Mean +- std dev: 2.00 us +- 0.04 us

./python.exe -m pyperf timeit "set((1, 2, 3, 4, 5))"
.....................
Mean +- std dev: 1.65 us +- 0.04 us

./python.exe -m pyperf timeit "set()"
.....................
Mean +- std dev: 448 ns +- 15 ns

Master

./python.exe -m pyperf timeit "set([1, 2, 3, 4, 5])"
.....................
Mean +- std dev: 2.30 us +- 0.04 us

./python.exe -m pyperf timeit "set((1, 2, 3, 4, 5))"
.....................
Mean +- std dev: 1.84 us +- 0.05 us

./python.exe -m pyperf timeit "set()"
.....................
Mean +- std dev: 528 ns +- 16 ns

https://bugs.python.org/issue37207

Copy link
Member
@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When doing benchmarks, you can use two Python binaries and use pyperf timeit --compare-to=REF_PYTHON_BINARY (...). It checks that the difference is significant.
https://pyperf.readthedocs.io/en/latest/cli.html#pyperf-timeit

Or you can store results in JSON files and use pyperf compare_to command.

@vstinner
Copy link
Member

I merged PR #18980, please rebase your PR on top of master and modify your PR to use _PyArg_NoKwnames().

Copy link
Member
@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@vstinner
Copy link
Member

IMHO it's worth it to add a few lines of C code to make tuple() and set() constructors faster.

@corona10
Copy link
Member Author

IMHO it's worth it to add a few lines of C code to make tuple() and set() constructors faster

Yeah, I think the PEP 590 implemented very well to bring performance enhancement very easily.

@vstinner
Copy link
Member

Yeah, I think the PEP 590 implemented very well to bring performance enhancement very easily.

What I mean is that vectorcall should not be used for everything. But set() and tuple() are very commonly used, so here it's worth it.

@vstinner vstinner merged commit 6ff79f6 into python:master Mar 16, 2020
@corona10 corona10 deleted the bpo-37207-set branch March 18, 2020 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0