Issue 31983: Officially add Py_SETREF and Py_XSETREF (original) (raw)

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/76164

classification

Title: Officially add Py_SETREF and Py_XSETREF
Type: enhancement Stage: resolved
Components: Documentation, Interpreter Core Versions: Python 3.7

process

Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, rhettinger, serhiy.storchaka, vstinner
Priority: normal Keywords:

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

Messages (5)
msg305878 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-11-08 16:24
Private macros Py_SETREF and Py_XSETREF were introduced in 3.6 and backported to all maintained versions for fixing bugs (see and ). They are helpful and used not only for the primary purpose, but also for simplifying the code. Their names don't start from underscore because I planned to make them public and didn't want massive renaming and backporting conflicts. Now I think it is a time to add them officially to the stable C API.
msg305888 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2017-11-08 18:06
Just adding +1.
msg305889 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-11-08 18:48
Does anyone want to propose a patch? This is mainly a documentation issue. Needed documenting Py_SETREF and Py_XSETREF in Doc/c-api/refcounting.rst, adding entries in Doc/whatsnew/3.7.rst, and "Misc/NEWS.d/next/C API/", and updating a guard in Include/object.h.
msg306284 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-11-15 16:37
Adding my -1. My experience was that these macros impaired my ability to maintain the code and interfered with useful patterns like delaying all decrefs until an object was in a consistent state. While I know that name was bikeshedded quite a bit, the outcome is rather unintuitive: https://twitter.com/raymondh/status/930535938459025408
msg309033 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-12-25 09:30
Since there are objections, it is too early to make this a public C API.
History
Date User Action Args
2022-04-11 14:58:54 admin set github: 76164
2017-12-25 09:30:41 serhiy.storchaka set status: open -> closedresolution: rejectedmessages: + stage: needs patch -> resolved
2017-11-15 16:37:11 rhettinger set nosy: + rhettingermessages: +
2017-11-15 09🔞03 skrah set nosy: - skrah
2017-11-08 18:48:02 serhiy.storchaka set messages: + stage: needs patch
2017-11-08 18:06:31 skrah set nosy: + skrahmessages: +
2017-11-08 16:25:17 vstinner set nosy: + vstinner
2017-11-08 16:24:41 serhiy.storchaka create