]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-135573: Make pickled lists, sets and dicts a tiny bit smaller (GH-144162)
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 18 Feb 2026 11:20:31 +0000 (13:20 +0200)
committerGitHub <noreply@github.com>
Wed, 18 Feb 2026 11:20:31 +0000 (13:20 +0200)
commit7ac0868708f342b8990404174a4d200105a4f728
tree5ce9b45ce053b74e1e31f3d0feb589fa238c535d
parent9e8fa2d4d1ec263bdc6945237b0e0517f07a3474
gh-135573: Make pickled lists, sets and dicts a tiny bit smaller (GH-144162)

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, ...
Modules/_pickle.c