Efficient, Pythonic bidirectional map implementation and related functionality.

bidict logo


Latest release Documentation Travis-CI build status AppVeyor (Windows) build status Test coverage Codacy grade License


  • is in use by several teams at Google, Venmo, Bank of America Merrill Lynch, Two Sigma, and many others,
  • has carefully designed APIs for safety, simplicity, flexibility, and ergonomics,
  • is CPython-, PyPy-, Python 2-, and Python 3-compatible,
  • has extensive test coverage, including property-based tests and benchmarks, which are run continuously on all supported Python versions and OSes,
  • integrates with Python’s collections interfaces and abstract base classes,
  • has mature, well-factored, well-documented code.


pip install bidict

Quick Start

>>> from bidict import bidict
>>> element_by_symbol = bidict({'H': 'hydrogen'})
>>> element_by_symbol['H']
>>> element_by_symbol.inv['hydrogen']

For more usage documentation, head to the Introduction [1] and proceed from there.

Community and Support


If you are thinking of using bidict in your work, or if you have any questions, comments, or suggestions, I’d love to know about your use case and provide as much support for it as possible.

Please feel free to leave a message in the chatroom or to open a new issue on GitHub. Don’t forget to search through existing issues first and to review the Contributors’ Guide [2].

Notice of Usage

If you are already using bidict, and especially if you/your organization is a significant user, please let me know you’re using it!

You can email me, open an issue, or leave a message in the chat room.


See the Changelog [3] for a history of notable changes to bidict.

Release Notifications

Follow on Sibbell

Tip: Follow bidict on Sibbell to be notified when a new version of bidict is released.

Learning from bidict

One of the most rewarding things about working on bidict – and also the most surprising, especially in light of the small codebase (just ~600 sloc) – is how much fun, advanced Python material has turned up in the process.

Check out the Learning from bidict [4] docs if you’re interested in taking a tour.


Bidict is currently a one-person operation maintained on a voluntary basis for the public good. Your help would be most welcome.

If bidict has helped you accomplish your work, especially work you’ve been paid for, please consider supporting bidict’s maintenance and development.

Support bidict

For information about contributing to the code, please see the Contributors’ Guide. [2]

Finding Documentation

If you’re viewing this on, note that multiple versions of the documentation are available, and you can choose a different version using the popup menu at the bottom-right. Please make sure you’re viewing the version of the documentation that corresponds to the version of bidict you’d like to use.

If you’re viewing this on GitHub, PyPI, or some other place that can’t render and link this documentation properly and are seeing broken links, try these alternate links instead:

[1]docs/intro.rst |
[2](1, 2) CONTRIBUTING.rst |
[3]CHANGELOG.rst |
[4]docs/learning-from-bidict.rst |