-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-131510: Deprecate PyUnicodeObject structs, revert memory layout #130697
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
Conversation
Deprecate `PyASCIIObject`, `PyCompactUnicodeObject`, `PyUnicodeObject` structs, and the `PyUnicode_IS_COMPACT` macro. Schedule removal for 3.16, the shortest non-exceptional deprecation period per PEP-387. The structs are blocking development of the free-threaded build (bitfields can't be used atomically) and of possible UTF-8-focused string representations. In non-free-threaded builds, revert `PyASCIIObject` to the binary layout used in 3.13. For free-threaded builds, use `alignas` instead of padding to ensure alignment. All relevant compilers support `alignas`, as do the C11 & C++11 standards, but they may need different spelling or compiler options for it.
|
I'll look at the compile errors later. (Thank you GHA; I can't easily do a matrix build locally.) |
| && (defined(__GNUC__) || defined(__clang__)) | ||
| # define _Py_ALIGN_AS(V) __attribute__((aligned(V))) | ||
| # else | ||
| # define _Py_ALIGN_AS(V) alignas(V) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be used if __cplusplus < 201103L and neither __GNUC__ nor __clang__ are defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's unknown compilers that aren't in C++11+-standard mode.
IMO, the best we can do is hope that they do support this part of C++11.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if it is an old Microsoft compiler? Then we could use __declspec(align(V)).
|
It's not yet time to deprecate these. I'll send a new PR for the memory layout revert. |
(Draft for discussion with the C API WG.)
Deprecate
PyASCIIObject,PyCompactUnicodeObject,PyUnicodeObjectstructs, and thePyUnicode_IS_COMPACTmacro.Schedule removal for 3.16, the shortest non-exceptional deprecation period per PEP-387. The structs are blocking development of the free-threaded build (bitfields can't be used atomically) and of possible UTF-8-focused string representations.
Add an example of what I'd like to see in porting notes for a deprecation.
In non-free-threaded builds, revert
PyASCIIObjectto be ABI-compatible with in 3.13.For free-threaded builds, use
alignasinstead of padding to ensure alignment.All relevant compilers support
alignas, as do the C11 & C++11 standards, but they may need different spelling or compiler options for it.Introduce
_Py_ALIGN_ASfor this.📚 Documentation preview 📚: https://cpython-previews--130697.org.readthedocs.build/