Skip to content

gh-161106: Use repeat counts in plistlib binary writer struct formats - #161107

Merged
gpshead merged 1 commit into
python:mainfrom
gpshead:plistlib-struct-repeat-counts
Nov 1, 2026
Merged

gpshead merged 1 commit into
python:mainfrom
gpshead:plistlib-struct-repeat-counts

Conversation

@gpshead

@gpshead gpshead commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Use repeat-count struct formats (f'>{n}{code}') for the array and dict reference lists and the offset table in the binary plist writer, matching what the reader has done since gh-86269. A compiled '>' + code * n format takes about 33 bytes per item and stays in the struct module's format cache after dumps() returns; a repeat-count format is constant size. The packed bytes are identical.

Fixes #161106

ANT-2026-1L9EBYNF

…ormats

Compiled struct formats with one code per item stay in the struct
module's cache and take about 33 bytes per item.  Use the repeat-count
form the reader already uses; the output is unchanged.
@gpshead gpshead added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Nov 1, 2026
@gpshead gpshead self-assigned this Nov 1, 2026
@gpshead gpshead added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Nov 1, 2026
@gpshead
gpshead marked this pull request as ready for review November 1, 2026 18:23
@gpshead
gpshead enabled auto-merge (squash) November 1, 2026 18:23
@gpshead
gpshead merged commit 4b21d15 into python:main Nov 1, 2026
112 of 114 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @gpshead for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@bedevere-app

bedevere-app Bot commented Nov 1, 2026

Copy link
Copy Markdown

GH-161137 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Nov 1, 2026
@bedevere-app

bedevere-app Bot commented Nov 1, 2026

Copy link
Copy Markdown

GH-161138 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Nov 1, 2026
gpshead added a commit that referenced this pull request Nov 1, 2026
…formats (GH-161107) (#161137)

Compiled struct formats with one code per item stay in the struct
module's cache and take about 33 bytes per item.  Use the repeat-count
form the reader already uses; the output is unchanged.

ANT-2026-1L9EBYNF

(cherry picked from commit 4b21d15)
gpshead added a commit that referenced this pull request Nov 1, 2026
…formats (GH-161107) (#161138)

Compiled struct formats with one code per item stay in the struct
module's cache and take about 33 bytes per item.  Use the repeat-count
form the reader already uses; the output is unchanged.

ANT-2026-1L9EBYNF

(cherry picked from commit 4b21d15)
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.

plistlib binary writer leaves large formats in the struct cache

1 participant