Description
Feature or enhancement
Proposal:
This is an issue to track the progress of using macros (for now internally) instead of using &_Py_STR(empty)
, &_Py_SINGLETON(bytes_empty)
and &_Py_SINGLETON(tuple_empty)
.
Note that we already have a public API for 0/1 so I won't touch them. However, for strings and bytes, it could be better to use the global singletons instead. Note that using the public Py_GetConstant
or Py_GetConstantBorrowed
(it's the same anyway since those constants are immortal) is not possible because the constants being returned are first constructed using other public functions (e.g., PyUnicode_New(0, 0)
which itself returns the immortal empty string singleton; in particular, you cannot make Py_GetConstantBorrow(Py_CONSTANT_EMPTY_STR)
a macro and use it inside PyUnicode_New(0, 0)
due to recursion issues and other compilation issues).
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
- Add PyBytes_Join() function capi-workgroup/decisions#36 (comment)
- gh-123660: Internal macros for accessing empty string/bytes singletons #123643 (comment)