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: Add _PyTuple_Empty and make PyTuple_New(0) never failing
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.7
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: rhettinger, serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2017-04-25 16:51 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1283 closed serhiy.storchaka, 2017-04-25 16:56
Messages (4)
msg292274 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-04-25 16:51
Proposed patch makes the empty tuple be allocated in static memory rather than dynamic memory, expose a reference to it as _PyTuple_Empty, and makes PyTuple_New(0) never raising exceptions. This allows to simplify the code. No longer need to call PyTuple_New(0), check it's result for errors, and clean up it after the use, you just can use a borrowed reference _PyTuple_Empty.

_PyTuple_Empty is for CPython internal use only.
msg292297 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-04-26 04:03
The patch shows a nice payoff from this short-cut, so go ahead and apply it.

Still, I wish there were some aversion to posting a new patch every two days that alters twenty files all over the standard library.  The rate of churn is alarming.
msg350453 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-08-25 13:21
Closed because several commenters found things to not like about it.
msg350570 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-08-26 21:35
We could add a _PyTuple_Init() function to ensure that the empty tuple singleton is created as soon as possible, as call it early, in pycore_init_types().
History
Date User Action Args
2022-04-11 14:58:45adminsetgithub: 74348
2019-08-26 21:35:12vstinnersetmessages: + msg350570
2019-08-25 13:21:03serhiy.storchakasetstatus: open -> closed
resolution: rejected
messages: + msg350453

stage: patch review -> resolved
2017-04-26 04:03:43rhettingersetnosy: + rhettinger
messages: + msg292297
2017-04-25 16:56:01serhiy.storchakasetpull_requests: + pull_request1391
2017-04-25 16:51:52serhiy.storchakacreate