A data-structure for 1:1 mappings in python?

前端 未结 8 1527
广开言路
广开言路 2020-12-17 08:17

I have a problem which requires a reversable 1:1 mapping of keys to values.

That means sometimes I want to find the value given a key, but at other times I want to

8条回答
  •  无人及你
    2020-12-17 08:44

    How about using sqlite? Just create a :memory: database with a two-column table. You can even add indexes, then query by either one. Wrap it in a class if it's something you're going to use a lot.

提交回复
热议问题