Provide a C-API to efficently convert `dict` into `frozendict`

I’d be okay with an API that explicitly leaves the original dict alive but empty. If we make it steal the reference, we can keep any last-reference optimisations fully internal. For uses that know they have the sole reference, it’s basically the same as a “more efficient” API, but we also get to have deterministic behaviour (if perhaps not so useful).

Leaving the original dict alive but in a “throws if used” error state might make more sense, but it doesn’t currently exist, and adding it might be too big.

1 Like