You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some context, I changed this in #3330. I removed the "infallible" version but perhaps that was too aggressive and we can bring it back with an awkward name and a strong recommendation not to use it except in performance sensitive cases.
It's possible there are ways that we could make error handling overhead lighter, those would need exploration.
Also for freethreaded Python PyDict_GetItemRef is strongly recommended to avoid race conditions, which is a reason not to expose an API wrapping PyDict_GetItem as it is not thread safe.
This will be helpful in micro optimizations where we don't care about errors and we are okay to get
None
.The current implementation of
get_item
usesPyDict_GetItemWithError
which creates a little overhead while taking Python errors.pyo3/src/types/dict.rs
Lines 431 to 438 in dcba984
The overhead could be pretty displayed using flame graph:
The right side with
PyErr::take
could goneThe solution is to add new method
get_item_TBD
which will usePyDict_GetItem
insteadThe text was updated successfully, but these errors were encountered: