[pycore] internal macros for accessing empty string/bytes and other singletons #123660
Labels
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
type-feature
A feature request or enhancement
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
orPy_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 makePy_GetConstantBorrow(Py_CONSTANT_EMPTY_STR)
a macro and use it insidePyUnicode_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:
Linked PRs
The text was updated successfully, but these errors were encountered: