Skip to content

[pycore] internal macros for accessing empty string/bytes and other singletons #123660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
picnixz opened this issue Sep 4, 2024 · 1 comment
Closed
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@picnixz
Copy link
Member

picnixz commented Sep 4, 2024

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:

Linked PRs

@picnixz picnixz added type-feature A feature request or enhancement interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Sep 4, 2024
@picnixz picnixz changed the title [pycore] internal macros for accessing empty string/bytes singletons [pycore] internal macros for accessing empty string/bytes and other singletons Sep 4, 2024
@picnixz
Copy link
Member Author

picnixz commented Nov 12, 2024

Closing since #115754 actually took care of the stable ABI and that internal usage could be fine. We can revisit it in the future if needed.

@picnixz picnixz closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant