`IntoPyObject` doesn't intern dictionary keys
Author: vasiliy-poverennov-ddCreated Sep 17, 2026Updated Sep 17, 2026
Bug Description
Not sure if this should be a bug or a feature request
it was surprising behavior for me and we had to switch from using derive to manually implementing IntoPyObject for some of the structs that get converted to python a lot to take advantage of key interning
FromPyObject derive interns the keys, IntoPyObject / IntoPyObjectRef don't - is this by design or an oversight? I think I should be able to put up a PR if you want this fixed
Steps to Reproduce
use IntoPyObject on a struct
Backtrace
Your operating system and version
MacOS 26
Your Python version (python --version)
Python 3.12.11
Your Rust version (rustc --version)
rustc 1.94.1
Your PyO3 version
0.29.2
How did you install python? Did you use a virtualenv?
not relevant
Additional Info
No response
Source: PyO3/pyo3