Skip to content

perf: share repeated source message IDs when reading PO catalogs - #1395

Open
SAY-5 wants to merge 1 commit into
python-babel:masterfrom
SAY-5:fix/po-message-id-sharing-20261018
Open

SAY-5 wants to merge 1 commit into
python-babel:masterfrom
SAY-5:fix/po-message-id-sharing-20261018

Conversation

@SAY-5

@SAY-5 SAY-5 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

read_po (and PoFileParser) now take an optional shared_msgids dict. Identical message IDs within one file always share a string object, and passing the same dict to several read_po calls shares them between catalogs too, which is what #571 is after, without sys.intern or any free-threading check.

Refs #571.

@akx akx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of using sys.intern, what about just having a temporary dict of these strings within the parser? That would work for free-threaded builds too.

@SAY-5

SAY-5 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Switched to a dict on the parser, dropped sys.intern and the build check, and cut the tests down to a single case in test_pofile_read.py. It only dedups within one read_po call now (e.g. the same msgid under different contexts), so separately loaded catalogs no longer share IDs.

@akx

akx commented Oct 30, 2026

Copy link
Copy Markdown
Member

Hmmmn, sorry, I had forgotten to actually read the context of #571 before suggesting the per-parser dict. I'd just rather not like to have to probe around for whether we're doing free-threading...

@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.68%. Comparing base (aeca9fa) to head (997b084).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1395   +/-   ##
=======================================
  Coverage   93.67%   93.68%           
=======================================
  Files          27       27           
  Lines        4983     4987    +4     
=======================================
+ Hits         4668     4672    +4     
  Misses        315      315           
Flag Coverage Δ
macos-26-3.10 92.76% <100.00%> (+<0.01%) ⬆️
macos-26-3.11 ?
macos-26-3.12 92.96% <100.00%> (+<0.01%) ⬆️
macos-26-3.13 92.96% <100.00%> (+<0.01%) ⬆️
macos-26-3.14 ?
macos-26-3.15 92.94% <100.00%> (+<0.01%) ⬆️
macos-26-3.9 92.69% <100.00%> (+<0.01%) ⬆️
macos-26-pypy3.11 92.70% <100.00%> (+<0.01%) ⬆️
macos-26-pypy3.12 92.96% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.10 92.78% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.11 92.72% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.12 92.98% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.13 92.98% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.14 92.96% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.15 92.96% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.9 92.71% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-pypy3.11 92.72% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-pypy3.12 92.98% <100.00%> (+<0.01%) ⬆️
windows-2025-3.10 92.77% <100.00%> (+<0.01%) ⬆️
windows-2025-3.11 92.71% <100.00%> (+<0.01%) ⬆️
windows-2025-3.12 92.97% <100.00%> (+<0.01%) ⬆️
windows-2025-3.13 92.97% <100.00%> (+<0.01%) ⬆️
windows-2025-3.14 92.95% <100.00%> (+<0.01%) ⬆️
windows-2025-3.15 92.95% <100.00%> (+<0.01%) ⬆️
windows-2025-3.9 92.70% <100.00%> (+<0.01%) ⬆️
windows-2025-pypy3.11 92.71% <100.00%> (+<0.01%) ⬆️
windows-2025-pypy3.12 92.97% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed

codspeed Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 88 untouched benchmarks


Comparing SAY-5:fix/po-message-id-sharing-20261018 (997b084) with master (aeca9fa)

Open in CodSpeed

@SAY-5
SAY-5 force-pushed the fix/po-message-id-sharing-20261018 branch from 4da5393 to 79b1b5a Compare November 12, 2026 23:27
@SAY-5

SAY-5 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

No worries. read_po now takes an optional shared_msgids dict (the parser still uses its own one by default), so passing the same dict for every catalog shares the IDs across them like the snippet in #571, with no sys.intern or free-threading check.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@SAY-5
SAY-5 force-pushed the fix/po-message-id-sharing-20261018 branch from 79b1b5a to 997b084 Compare November 16, 2026 15:51

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants