Skip to content

[3.14] gh-133968: Add PyUnicodeWriter_WriteASCII() function (#133973) #134974

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

Merged
merged 1 commit into from
Jun 9, 2025

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented May 31, 2025

Replace most PyUnicodeWriter_WriteUTF8() calls with PyUnicodeWriter_WriteASCII().

(cherry picked from commit f49a07b)


📚 Documentation preview 📚: https://cpython-previews--134974.org.readthedocs.build/

@vstinner
Copy link
Member Author

@hugovk: Hi, can I have an exception to add this late feature into Python 3.14 after the feature freeze? It was decided late but it comes with the PyUnicodeWriter which was just added to Python 3.14.

This change fix also a performance regression compared to Python 3.13: Using the public PyUnicodeWriter C API made the json module slower.

@zooba wrote:

I'd check with the RM about adding it to 3.14 as well. I suspect it should be okay - there's no compatibility impact, and it'll save introducing one by having to choose a different API between 3.14/3.15.

…3973)

Replace most PyUnicodeWriter_WriteUTF8() calls with
PyUnicodeWriter_WriteASCII().

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
(cherry picked from commit f49a07b)
@vstinner
Copy link
Member Author

vstinner commented Jun 2, 2025

I used git push --force to remove this change from the PR and the commit message:

Unrelated change to please the linter: remove an unused import in test_ctypes.

@vstinner
Copy link
Member Author

vstinner commented Jun 5, 2025

Ping @hugovk.

@hugovk
Copy link
Member

hugovk commented Jun 9, 2025

This is okay for 3.14.

On success, return ``0``.
On error, set an exception, leave the writer unchanged, and return ``-1``.

.. versionadded:: next
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need updating in main to 3.14.

@vstinner vstinner merged commit 3d69d18 into python:3.14 Jun 9, 2025
41 checks passed
@vstinner vstinner deleted the write_ascii14 branch June 9, 2025 12:37
@vstinner
Copy link
Member Author

vstinner commented Jun 9, 2025

Follow-up:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants