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.

Title: Initialize Py_buffer variables more efficiently
Type: performance Stage: patch review
Components: Argument Clinic Versions: Python 3.9
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: larry, sir-sigurd
Priority: normal Keywords: patch

Created on 2019-08-13 16:37 by sir-sigurd, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 15254 open sir-sigurd, 2019-08-13 16:38
Messages (1)
msg349582 - (view) Author: Sergey Fedoseev (sir-sigurd) * Date: 2019-08-13 16:37
Argument Clinic generates `{NULL, NULL}` initializer for Py_buffer variables. Such initializer zeroes all Py_buffer members, but as I understand only `obj` and `buf` members are really had to be initialized. Avoiding unneeded initialization provides tiny speed-up:

$ python -m perf timeit -s "replace = b''.replace" "replace(b'', b'')" --compare-to=../cpython-master/venv/bin/python --duplicate=1000
/home/sergey/tmp/cpython-master/venv/bin/python: ..................... 43.0 ns +- 0.5 ns
/home/sergey/tmp/cpython-dev/venv/bin/python: ..................... 41.8 ns +- 0.4 ns

Mean +- std dev: [/home/sergey/tmp/cpython-master/venv/bin/python] 43.0 ns +- 0.5 ns -> [/home/sergey/tmp/cpython-dev/venv/bin/python] 41.8 ns +- 0.4 ns: 1.03x faster (-3%)
Date User Action Args
2022-04-11 14:59:19adminsetgithub: 82023
2019-08-13 16:38:30sir-sigurdsetkeywords: + patch
stage: patch review
pull_requests: + pull_request14975
2019-08-13 16:37:28sir-sigurdcreate