New submission from Sergey Fedoseev <fedoseev.ser...@gmail.com>:
PyTuple_New() fills items array with NULLs to make usage of Py_DECREF() safe even when array is not fully filled with real items. There are multiple cases when this initialization step can be avoided to improve performance. For example it gives such speed-up for PyList_AsTuple(): Before: $ python -m perf timeit -s "l = [None] * 10**6" "tuple(l)" ..................... Mean +- std dev: 4.43 ms +- 0.01 ms After: $ python -m perf timeit -s "l = [None] * 10**6" "tuple(l)" ..................... Mean +- std dev: 4.11 ms +- 0.03 ms ---------- messages: 335897 nosy: sir-sigurd priority: normal severity: normal status: open title: add internal API function to create tuple without items array initialization type: performance versions: Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36030> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com