This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: enumerate() instantiation time reducing by using PEP 590 vectorcall
Type: performance Stage: resolved
Components: Versions: Python 3.11
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: JelleZijlstra, corona10, kj, vstinner, xtreak
Priority: normal Keywords: patch

Created on 2021-04-02 17:36 by corona10, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bench_enumerate.py corona10, 2021-04-02 17:36
Pull Requests
URL Status Linked Edit
PR 25154 merged corona10, 2021-04-02 17:53
PR 30904 merged JelleZijlstra, 2022-01-26 03:39
Messages (5)
msg390083 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2021-04-02 17:36
Finally, I success to implement PEP 590 for enumerate type which is the well-used type in Python.

Amazingly enhanced!

+-----------------+------------------------+----------------------------+
| Benchmark       | enumerate_bench_master | enumerate_bench_vectorcall |
+=================+========================+============================+
| bench enumerate | 527 ns                 | 380 ns: 1.39x faster       |
+-----------------+------------------------+----------------------------+
msg404705 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2021-10-21 23:19
See my last benchmark

https://github.com/python/cpython/pull/25154#issuecomment-949061515

Same result in both Linux VM and Macbook pro.
msg404706 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2021-10-21 23:20
New changeset 83f202a802b0810e2f0900c6d298fd104390f2ba by Dong-hee Na in branch 'main':
bpo-43706: Use PEP 590 vectorcall to speed up enumerate() (GH-25154)
https://github.com/python/cpython/commit/83f202a802b0810e2f0900c6d298fd104390f2ba
msg404707 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2021-10-21 23:23
Thanks Victor!
msg404717 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2021-10-22 01:59
@vstinner

I noticed that the msg390083 was based on a non-optimized build.
https://github.com/python/cpython/pull/25154#issuecomment-949061515 ran with the same build option condition.

Here is the PGO + LTO based benchmark.
Still fast.

+-----------------+----------+----------------------+
| Benchmark       | base_opt | vectorcall_opt       |
+=================+==========+======================+
| bench enumerate | 384 ns   | 277 ns: 1.39x faster |
+-----------------+----------+----------------------+
History
Date User Action Args
2022-04-11 14:59:43adminsetgithub: 87872
2022-01-26 03:39:17JelleZijlstrasetnosy: + JelleZijlstra

pull_requests: + pull_request29083
2021-10-22 01:59:19corona10setmessages: + msg404717
2021-10-21 23:29:20corona10setversions: + Python 3.11, - Python 3.10
2021-10-21 23:23:14corona10setstatus: open -> closed

messages: + msg404707
stage: patch review -> resolved
2021-10-21 23:20:51corona10setmessages: + msg404706
2021-10-21 23:19:55corona10setnosy: + kj
2021-10-21 23:19:38corona10setmessages: + msg404705
2021-04-02 17:53:45corona10setkeywords: + patch
stage: patch review
pull_requests: + pull_request23901
2021-04-02 17:36:26corona10settype: performance
versions: + Python 3.10
2021-04-02 17:36:13corona10create