Immutable dictionary, only use as a key for another dictionary

前端 未结 8 2340
情歌与酒
情歌与酒 2020-12-05 04:52

I had the need to implement a hashable dict so I could use a dictionary as a key for another dictionary.

A few months ago I used this implementation: Python hashable

8条回答
  •  借酒劲吻你
    2020-12-05 05:21

    Here is a link to pip install-able implementation of @RaymondHettinger's answer: https://github.com/pcattori/icicle

    Simply pip install icicle and you can from icicle import FrozenDict!

    Update: icicle has been deprecated in favor of maps: https://github.com/pcattori/maps (documentation, PyPI).

提交回复
热议问题