Bug report
Bug description:
The pickletools.optimize code suddenly performs bad starting with python 3.14, with or without JIT.
The degradation is a factor 3 to 4.
It is easy to test.
First use this script to make a sizeable dict and pickle it and write it to file.
import pickle
x = {}
for i in range(1, 1000000):
x[i] = f"ii{i:>07}"
with open("pickled", "wb") as fh:
pickle.dump(x, fh, protocol=4)
Then write a script, let's call it optpickle.py to read the pickled dict from file and optimize it and write the result to another file.
# optpickle.py
import pickletools
with open("pickled", "rb") as fh:
p = fh.read()
s = pickletools.optimize(p)
with open("pickledopt", "wb") as fh:
fh.write(s)
Now execute this in three separate terminal windows, one geared to python 3.13, one to python 3.14.0 without JIT, and one to python 3.14.0 with JIT.
My results on a mac with M1 processor were
| version |
time elapsed |
cpu time |
| 3.13 |
1.67 |
1.773 |
| 3.14.0 no JIT |
6.52 |
6.664 |
| 3.14.0 JIT |
6.52 |
6.642 |
That is a dramatic drop in performance!
The filesizes are 16.9 MB for the unoptimized file and 15.9 for the optimized one.
I decided to drop the optimization in an app where I used it heavily
CPython versions tested on:
3.14
Operating systems tested on:
macOS
Bug report
Bug description:
The pickletools.optimize code suddenly performs bad starting with python 3.14, with or without JIT.
The degradation is a factor 3 to 4.
It is easy to test.
First use this script to make a sizeable dict and pickle it and write it to file.
Then write a script, let's call it
optpickle.pyto read the pickled dict from file and optimize it and write the result to another file.Now execute this in three separate terminal windows, one geared to python 3.13, one to python 3.14.0 without JIT, and one to python 3.14.0 with JIT.
My results on a mac with M1 processor were
That is a dramatic drop in performance!
The filesizes are 16.9 MB for the unoptimized file and 15.9 for the optimized one.
I decided to drop the optimization in an app where I used it heavily
CPython versions tested on:
3.14
Operating systems tested on:
macOS