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-157407: Reduce code size of ast and unicodeobject by methane · Pull Request #157393 · python/cpython

Conversation

@methane

@methane methane commented Sep 13, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

This pull request refactors and optimizes the initialization and cleanup code for AST annotations and global static strings, focusing on reducing .text segment size.
This change reduces the size of Python's .text segment by approximately 1%, or about 60 KiB.

The main changes involve switching to offset-based iteration for both AST type cleanup and string initialization, and consolidating annotation logic to avoid code duplication.

Disclosure of the use of AI:

  • This change was selected and refined by me from a set of code-size reduction changes generated by Codex.
  • The description above was edited by me based on Copilot's "Generate Summary."
  • This text was translated into English by ChatGPT from the Japanese text I wrote.
  • Issue: Reduce some code sizes #157407

Sorry, something went wrong.

Uh oh!

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

eendebakpt reacted with eyes emoji
All reactions
  • 👀 1 reaction
@methane
reduce .text size
cf44a1a
@methane
methane requested a review from ericsnowcurrently as a code owner September 13, 2026 04:14
@methane methane added the skip issue label Sep 13, 2026
@methane
methane requested review from lysnikolaou and pablogsal as code owners September 13, 2026 04:14
@methane methane added the skip news label Sep 13, 2026
@bedevere-app bedevere-app Bot added the awaiting core review label Sep 13, 2026
@picnixz

picnixz commented Sep 13, 2026

Copy link
Copy Markdown
Member

Can you create an issue for such changes please? just for tracking purposes

All reactions

Sorry, something went wrong.

Uh oh!

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

@methane
fix check-c-globals
851f123
@methane methane changed the title reduce .text size gh-157407: Reduce code size of ast and unicodeobject Sep 13, 2026
@methane

methane commented Sep 13, 2026

Copy link
Copy Markdown
Member Author

This pr reduces:

  • add_ast_annotations: 48K bytes
  • _PyAST_Fini : 13K bytes
  • _PyUnicode_InitGlobalObjects : 10K bytes
All reactions

Sorry, something went wrong.

Uh oh!

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

@methane methane removed the skip issue label Sep 13, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Sep 13, 2026
Reduce some code sizes #157407
Open
eendebakpt
eendebakpt reviewed Sep 21, 2026
View reviewed changes
Comment thread Python/Python-ast.c Resolved

Uh oh!

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

Comment thread Parser/asdl_c.py Resolved

Uh oh!

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

@methane
fix indent and use more compact table
b22fdca
eendebakpt
eendebakpt reviewed Sep 21, 2026
View reviewed changes
Comment thread Parser/asdl_c.py Resolved

Uh oh!

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

Comment thread Tools/build/generate_global_objects.py Resolved

Uh oh!

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

Comment thread Parser/asdl_c.py Resolved

Uh oh!

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

methane
methane commented Sep 22, 2026
View reviewed changes
Comment thread Parser/asdl_c.py Resolved

Uh oh!

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

methane and others added 3 commits September 22, 2026 12:34
@methane @eendebakpt
Apply batched suggestions from code review
59734b4
Co-authored-by: Pieter Eendebak <[email protected]>
Co-authored-by: Inada Naoki <[email protected]>
@methane
fixup and regen
d54cc70
@methane
make regen-all
21bc6fc
@methane
methane merged commit 16b357b into python:main Sep 23, 2026
52 checks passed

Uh oh!

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

@bedevere-app bedevere-app Bot removed the awaiting core review label Sep 23, 2026
@hugovk

hugovk commented Sep 23, 2026

Copy link
Copy Markdown
Member

Looks like this caused test_peg_generator to fail on a number of AMD64 Windows (tier 1) buildbots:

Python-ast.c(835): error C2099: initializer is not a constant

For example: https://buildbot.python.org/#/builders/1620/builds/4536

All reactions

Sorry, something went wrong.

Uh oh!

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

@methane methane mentioned this pull request Sep 24, 2026
gh-157407: Fix a compilation error on Windows. #158048
Merged
methane added a commit that referenced this pull request Sep 24, 2026
@methane
gh-157407: Fix a compilation error on Windows. (#158048)
bd0913a
`&PyUnicode_Type` cannot be determined at compile time on Windows.
Caused by #157393.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@eendebakpt eendebakpt eendebakpt left review comments
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@pablogsal pablogsal Awaiting requested review from pablogsal pablogsal is a code owner
@lysnikolaou lysnikolaou Awaiting requested review from lysnikolaou lysnikolaou is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

skip news

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.

4 participants

@methane @picnixz @hugovk @eendebakpt
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.