Skip to content

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