GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-157407: Shrink _PyArg_Parser and don't write builtin parsers at run time by eendebakpt · Pull Request #157531 · python/cpython Conversation
|
| .data | .text | file | |
|---|---|---|---|
Windows python316.dll (MSVC) |
−11,528 | +48 | −11,264 |
Windows, all *.pyd + dll |
−22,008 | +48 | −24,064 |
Linux python (gcc 15, static libpython) |
−9,120 | +192 | |
Linux, python + all *.so |
−17,408 | +192 |
Possible follow-ups
With some more refactoring this could go further:
format, min or max. Builtin-module parsers also never use once, is_kwtuple_owned or next. A separate, smaller struct for them would save more memory, at the cost of changing the private API.fname, min and max for format-string parsers, so that builtin ones skip parser_init() too. parser_clear() then only needs to reset the kwtuple and once, since the other fields only depend on the static keywords and format.Generated with help from Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…cally Argument Clinic now sets _PyArg_Parser.pos statically. Parsers with a statically allocated keyword tuple (builtin modules) therefore need no initialization: _PyArg_UnpackKeywords() skips parser_init() for them, so they are never written to at run time. A lazily built keyword tuple is now published last, with _Py_atomic_store_ptr_release(). parser_clear() keeps pos, since it only depends on the keywords. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Narrow pos, min, max and is_kwtuple_owned, which are small counts, and remove custom_msg: it is only needed to report a conversion error, and can then be looked up in the format string. Keep format, keywords and fname first, so that existing positional initializers still work. _PyArg_Parser shrinks from 72 to 48 bytes on 64-bit platforms. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was an error while loading. Please reload this page.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…-shrink # Conflicts: # Modules/_ctypes/clinic/_ctypes.c.h # Modules/_io/clinic/bufferedio.c.h # Modules/_io/clinic/textio.c.h # Modules/_zstd/clinic/zstddict.c.h # Modules/clinic/_asynciomodule.c.h # Modules/clinic/_cursesmodule.c.h # Python/clinic/bltinmodule.c.h
…-shrink # Conflicts: # Modules/_io/clinic/bufferedio.c.h # Modules/_io/clinic/fileio.c.h # Modules/_io/clinic/iobase.c.h # Modules/_io/clinic/textio.c.h # Modules/_io/clinic/winconsoleio.c.h
There was an error while loading. Please reload this page.
|
Update: the followup ideas have been implemented in main...eendebakpt:feature/clinic-kwparser. That results in
I will look into opening a PR for that as an alternative for this PR. Update: and some more reduction: eendebakpt/cpython@main...feature/clinic-kwparser-split |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.