-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
gh-131510: Deprecate PyUnicodeObject structs, revert memory layout #130697
base: main
Are you sure you want to change the base?
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.
Discussion: https://discuss.python.org/t/deprecating-the-pyasciiobject-struct/82543 I'll look at the compile errors later. (Thank you GHA; I can't easily do a matrix build locally.) |
🤖 New build scheduled with the buildbot fleet by @encukou for commit 500b483 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F130697%2Fmerge If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
(Draft for discussion with the C API WG.)
Deprecate
PyASCIIObject
,PyCompactUnicodeObject
,PyUnicodeObject
structs, and thePyUnicode_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.
Add an example of what I'd like to see in porting notes for a deprecation.
In non-free-threaded builds, revert
PyASCIIObject
to be ABI-compatible with 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.Introduce
_Py_ALIGN_AS
for this.📚 Documentation preview 📚: https://cpython-previews--130697.org.readthedocs.build/