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.

Author sir-sigurd
Recipients sir-sigurd
Date 2019-02-19.08:02:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1550563364.86.0.164811838679.issue36030@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2019-02-19 08:02:44sir-sigurdsetrecipients: + sir-sigurd
2019-02-19 08:02:44sir-sigurdsetmessageid: <1550563364.86.0.164811838679.issue36030@roundup.psfhosted.org>
2019-02-19 08:02:44sir-sigurdlinkissue36030 messages
2019-02-19 08:02:44sir-sigurdcreate