Skip to content

gh-157407: Use _PyUnicode_AsUTF8NoNUL for AC 's' and 'z' converters - #158210

Merged
eendebakpt merged 5 commits into
python:mainfrom
cmaloney:clinic-s-z-asutf8nonul
Oct 5, 2026
Merged

eendebakpt merged 5 commits into
python:mainfrom
cmaloney:clinic-s-z-asutf8nonul

Conversation

@cmaloney

@cmaloney cmaloney commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

The code was doing the same as the helper added in GH-111957 but inline. That resulted in significantly more .text for most functions. Refactor the Argument Clinic converters code to deduplicate a bit while keeping generated code close to original.

On my Linux x64 box this reduces .text by ~6200 bytes in a clang release build (no PGO or LTO). Performance is flat.

The helper was already exported for _sqlite3, update the comment that it is used in AC generated code as well.

cc: @eendebakpt , @methane . Found this while working on moving str to Argument Clinic generated code. The call + local rather than pointer to stack member, particularly when -fstack-protector-strong is set as some distros do, gets a lot shorter.

…ters

The code was doing the same as the helper added in pythonGH-111957 but inline.
That resulted in significantly more `.text` for most functions. Refactor
the Arguemnt Clinic converters code to deduplicate a bit while keeping
generated code close to original.

On my Linux x64 box this reduces `.text` by ~6200 bytes in a clang
release build (no PGO or LTO). Performance is flat.

The helper was already exported for `_sqlite3`, update the comment that
it is used in AC generated code as well.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Comment thread Misc/NEWS.d/next/Tools-Demos/2026-09-25-17-30-00.gh-issue-157407.iOVPov.rst Outdated
Comment thread Include/internal/pycore_unicodeobject.h Outdated
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
# Conflicts:
#	Modules/_ctypes/clinic/_ctypes.c.h
#	Modules/_io/clinic/fileio.c.h
#	Modules/_io/clinic/textio.c.h
#	Modules/_io/clinic/winconsoleio.c.h
#	Modules/_sqlite/clinic/connection.c.h
#	Modules/cjkcodecs/clinic/multibytecodec.c.h
#	Modules/clinic/_dbmmodule.c.h
#	Modules/clinic/_elementtree.c.h
#	Modules/clinic/_gdbmmodule.c.h
#	Modules/clinic/_pickle.c.h
#	Modules/clinic/_testclinic.c.h
#	Modules/clinic/_tkinter.c.h
#	Modules/clinic/arraymodule.c.h
#	Modules/clinic/posixmodule.c.h
#	Modules/clinic/pyexpat.c.h
#	Objects/clinic/memoryobject.c.h
#	Python/clinic/bltinmodule.c.h
#	Python/clinic/sysmodule.c.h
@eendebakpt

Copy link
Copy Markdown
Contributor

@cmaloney Merge conflicts again. Can you resolve and maybe set auto-merge?

# Conflicts:
#	Modules/_testcapi/clinic/exceptions.c.h
@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Oct 5, 2026
@cmaloney

cmaloney commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@eendebakpt updated branch resolving conflicts. I can't set auto-merge / just a triager moving (hopefully) towards developer :)

@eendebakpt
eendebakpt enabled auto-merge (squash) October 5, 2026 16:48
@eendebakpt
eendebakpt merged commit cfd6cf7 into python:main Oct 5, 2026
64 checks passed
@cmaloney
cmaloney deleted the clinic-s-z-asutf8nonul branch October 5, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants