Skip to content

Add PyDict_AsFrozenDictAndClear C-API #153410

Description

@sobolevn

Feature or enhancement

Discussion: https://discuss.python.org/t/provide-a-c-api-to-efficently-convert-dict-into-frozendict/107754/10

Looks like that all agree that this API would be useful.
How it works?

  1. We create a dict by any existing C-API functions for PyDict_*.
  2. Then we call PyDict_AsFrozenDictAndClear which creates new frozendict instance from the existing dict with O(1) complexity
  3. It clears the initial dict and it can be decrefed by the caller if needed

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions