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
Currently, there's no clean way to create a frozendict instances from C code. We faced this in msgspec: Add frozendict support for 3.15+ msgspec/msgspec#1052 Since this is a project focused on performance, we don't quite like to use PyFrozenDict_New for this. Because it copies the dict we already have once again. It works for O(n) and uses more memory than it actually needs to
New proposed API solves this by coping existing keys and values from any dict with O(1) complexity. Which is much faster
All people in the discussion agreed that such API would be nice to have
Most people in the discussion agreed that the taking an existing dict and transforming it to frozendict seems like a way to go
So, here it is :)
Looking forward to hearing your feedback!
Discussion: https://discuss.python.org/t/provide-a-c-api-to-efficently-convert-dict-into-frozendict/107754/10
Issue: python/cpython#153410
PR: python/cpython#153413
Discussion summary:
frozendictinstances from C code. We faced this inmsgspec: Addfrozendictsupport for 3.15+ msgspec/msgspec#1052 Since this is a project focused on performance, we don't quite like to usePyFrozenDict_Newfor this. Because it copies the dict we already have once again. It works forO(n)and uses more memory than it actually needs todictwithO(1)complexity. Which is much fasterdictand transforming it tofrozendictseems like a way to goSo, here it is :)
Looking forward to hearing your feedback!