Bug Description
I've been naively enabling freelist to enhance performance of my applications. Turns out there's not a single case it helped the performance. Turns out the change #4902 caused a bottleneck that completely waives any benefits of using freelist - it's better to remove the feature altogether.
I digged deeper.
Fable 5 conclusion was: Short answer: because since PyO3 0.23.5 (Feb 2025), every freelist push and pop takes a std::sync::Mutex — on all builds, including GIL builds — and the locking overhead now exceeds what the freelist ever saved. I reproduced your observation in the container with a controlled experiment; the sign genuinely flipped.
Which makes sense to me and I think this observation is good.
Steps to Reproduce
- Use freelist
- Measure
Backtrace
Your operating system and version
Linux 6.18
Your Python version (python --version)
Python 3.14
Your Rust version (rustc --version)
rustc 1.96.0 (ac68faa20 2026-05-25)
Your PyO3 version
0.28.3
How did you install python? Did you use a virtualenv?
uv
Additional Info
Before Fable was restricted, I managed to ideate some ideas on potential ways forward: https://claude.ai/share/c18f23ad-b07e-4ffe-a285-bd40e92b81dd Do whatever you want with that information.
Bug Description
I've been naively enabling freelist to enhance performance of my applications. Turns out there's not a single case it helped the performance. Turns out the change #4902 caused a bottleneck that completely waives any benefits of using freelist - it's better to remove the feature altogether.
I digged deeper.
Fable 5 conclusion was: Short answer: because since PyO3 0.23.5 (Feb 2025), every freelist push and pop takes a std::sync::Mutex — on all builds, including GIL builds — and the locking overhead now exceeds what the freelist ever saved. I reproduced your observation in the container with a controlled experiment; the sign genuinely flipped.
Which makes sense to me and I think this observation is good.
Steps to Reproduce
Backtrace
Your operating system and version
Linux 6.18
Your Python version (
python --version)Python 3.14
Your Rust version (
rustc --version)rustc 1.96.0 (ac68faa20 2026-05-25)
Your PyO3 version
0.28.3
How did you install python? Did you use a virtualenv?
uv
Additional Info
Before Fable was restricted, I managed to ideate some ideas on potential ways forward: https://claude.ai/share/c18f23ad-b07e-4ffe-a285-bd40e92b81dd Do whatever you want with that information.