Skip to content

Comments

gh-135573: Make pickled lists, sets and dicts a tiny bit smaller#144162

Merged
serhiy-storchaka merged 1 commit intopython:mainfrom
serhiy-storchaka:pickle-batch
Feb 18, 2026
Merged

gh-135573: Make pickled lists, sets and dicts a tiny bit smaller#144162
serhiy-storchaka merged 1 commit intopython:mainfrom
serhiy-storchaka:pickle-batch

Conversation

@serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Jan 22, 2026

Ensure that APPENDS and SETITEMS are never used for a batch of size 1.
Ensure that ADDITEMS and SETITEMS are never used for a batch of size 0.

This harmonizes the C implementation with the Python implementation which already guarantees this and makes a pickle a tiny bit smaller with a tiny chance (about 0.1%).

Saves 1 byte for list and dict with size 1001, 2001, ...
Saves 2 bytes for set and dict with size 1000, 2000, ...

Ensure that APPENDS and SETITEMS are never used for a batch of size 1.
Ensure that ADDITEMS and SETITEMS are never used for a batch of size 0.

This harmonizes the C implementation with the Python implementation
which already guarantees this and makes a pickle a tiny bit smaller
with a tiny chance (about 0.1%).

Saves 1 byte for list and dict with size 1001, 2001, ...
Saves 2 bytes for set and dict with size 1000, 2000, ...
@serhiy-storchaka serhiy-storchaka merged commit 7ac0868 into python:main Feb 18, 2026
49 checks passed
@serhiy-storchaka serhiy-storchaka deleted the pickle-batch branch February 18, 2026 11:20
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.

1 participant