Skip to content
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

bpo-20180: Use argument clinic for dict.pop() and dict.popitem() #12792

Merged
merged 5 commits into from Apr 12, 2019

Conversation

methane
Copy link
Member

@methane methane commented Apr 12, 2019

@tirkarthi
Copy link
Member

tirkarthi commented Apr 12, 2019

Does this provide performance improvement for dict.pop ? I am using a non-PGO build for benchmarking.

➜  cpython git:(master) ./python.exe -m timeit -s 'd = {"a": 1}' 'd.pop("a", None)'
2000000 loops, best of 5: 125 nsec per loop
➜  cpython git:(master) ./python.exe -m timeit -s 'd = {"a": 1}' 'd.pop("a", None)'
2000000 loops, best of 5: 127 nsec per loop
➜  cpython git:(master) ./python.exe -m timeit -s 'd = {"a": 1}' 'd.pop("a", None)'
2000000 loops, best of 5: 127 nsec per loop
➜  cpython git:(pr_12792) ./python.exe -m timeit -s 'd = {"a": 1}' 'd.pop("a", None)'
5000000 loops, best of 5: 82.7 nsec per loop
➜  cpython git:(pr_12792) ./python.exe -m timeit -s 'd = {"a": 1}' 'd.pop("a", None)'
5000000 loops, best of 5: 80.3 nsec per loop
➜  cpython git:(pr_12792) ./python.exe -m timeit -s 'd = {"a": 1}' 'd.pop("a", None)'
5000000 loops, best of 5: 74.5 nsec per loop

@methane
Copy link
Member Author

methane commented Apr 12, 2019

@tirkarthi
Copy link
Member

tirkarthi commented Apr 12, 2019

Is it worth adding a NEWS entry for such speedups since this is a considerable one reducing 120ns to 80ns.

@methane
Copy link
Member Author

methane commented Apr 12, 2019

I am not sure about it.

Some methods changed from METH_VARARGS to METH_FASTCALL without NEWS entry.
For example, #9560, #9164.

@methane methane changed the title clinic: dict.pop() and dict.popitem() bpo-20180: Use argument clinic for dict.pop() and dict.popitem() Apr 12, 2019
@tirkarthi
Copy link
Member

tirkarthi commented Apr 12, 2019

My rationale towards adding them is that unless someones follows CPython commits these optimizations are hard to find. Adding them to changelog might encourage users and give better outlook on how CPython is getting faster, given that it's dict.pop which is slightly more common. But it's your call on adding a NEWS entry.

@methane methane merged commit 9e4f2f3 into python:master Apr 12, 2019
@methane methane deleted the dict-clinic branch Apr 12, 2019
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.

None yet

4 participants