GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-131510: Deprecate PyUnicodeObject structs, revert memory layout by encukou · Pull Request #130697 · python/cpython

Conversation

@encukou

@encukou encukou commented Feb 28, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

(Draft for discussion with the C API WG.)


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.
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/

  • Issue: Deprecate PyASCIIObject/PyUnicodeObject #131510

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
encukou added 2 commits February 28, 2025 18:03
@encukou
Deprecate PyUnicodeObject structs, revert memory layout
6d266ee
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.
@encukou
Fix footnote numbers
2611679
@encukou

encukou commented Feb 28, 2025

Copy link
Copy Markdown
Member Author

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.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

encukou added 6 commits March 3, 2025 17:41
@encukou
Add function for 'interned' writes; fix type for free-threaded builds…
2451a86
… (unit8)
@encukou
Define _Py_ALIGN_AS for GCC on C++03 and below
351f0e3
@encukou
Fix generators & run regen
f0fc819
@encukou
Use __declspec(align) on MSVC
19ed310
@encukou
Regen test_frozenmain
bf4086c
@encukou
Merge in the main branch
500b483
@encukou encukou added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 5, 2025
@bedevere-bot

bedevere-bot commented Mar 5, 2025

Copy link
Copy Markdown

🤖 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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 5, 2025
encukou added 2 commits March 20, 2025 14:34
@encukou
Merge in the main branch
849384e
@encukou
Use __attribute__ for GCC & clang pre-C11 pedantic mode
e247c74
@encukou encukou added skip news and removed skip news labels Mar 20, 2025
encukou added 3 commits March 20, 2025 15:12
@encukou
Make the structs PyUnstable
d10dcdc
@encukou
Add docs for unstable API
86d41ea
@encukou
Test PyUnstable_Unicode_GET_CACHED_HASH
87a5d30
@encukou encukou changed the title Deprecate PyUnicodeObject structs, revert memory layout gh-131510: Deprecate PyUnicodeObject structs, revert memory layout Mar 20, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Mar 20, 2025
Deprecate PyASCIIObject/PyUnicodeObject #131510
Closed
encukou added 4 commits March 20, 2025 16:12
@encukou
What's New for the additions
d5939cf
@encukou
versionadded, rewording
3c861bc
@encukou
blurb
6f23304
@encukou
regen
5dbd6db
@encukou encukou mentioned this pull request Mar 20, 2025
Deprecate & plan to remove PyASCIIObject & co. capi-workgroup/decisions#60
Closed
2 of 6 tasks
serhiy-storchaka
serhiy-storchaka reviewed Apr 7, 2025
View reviewed changes
Comment thread Include/pymacro.h
&& (defined(__GNUC__) || defined(__clang__))
# define _Py_ALIGN_AS(V) __attribute__((aligned(V)))
# else
# define _Py_ALIGN_AS(V) alignas(V)

@serhiy-storchaka serhiy-storchaka Apr 7, 2025

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@encukou encukou Apr 28, 2025

Copy link
Copy Markdown
Member Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Apr 28, 2025

Copy link
Copy Markdown
Member

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)).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@encukou

encukou commented Apr 28, 2025

Copy link
Copy Markdown
Member Author

It's not yet time to deprecate these. I'll send a new PR for the memory layout revert.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@encukou encukou closed this Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka left review comments
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently will be requested when the pull request is marked ready for review ericsnowcurrently is a code owner
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner will be requested when the pull request is marked ready for review AA-Turner is a code owner
@ZeroIntensity ZeroIntensity Awaiting requested review from ZeroIntensity ZeroIntensity will be requested when the pull request is marked ready for review ZeroIntensity is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@encukou @bedevere-bot @serhiy-storchaka
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.