bidict: The Bidirectional Mapping Library for Python

Summary
bidict is a mature and lightweight Python library designed for creating bidirectional mappings. It provides familiar, Pythonic APIs for safe, simple, and flexible data handling, making it a reliable choice for projects requiring efficient two-way lookups. Trusted by major organizations since 2009, bidict ensures robust and well-tested functionality.
Repository Info
Tags
Click on any tag to explore related repositories
Introduction
bidict is a robust Python library that provides bidirectional mapping capabilities, allowing you to easily look up values by keys and keys by values. Since its inception in 2009, it has been a trusted solution, relied upon by major organizations like Google, Venmo, CERN, Baidu, and Tencent for their data structure needs.
Installation
To get started with bidict, simply install it using pip:
pip install bidictExamples
Here's a quick example to demonstrate bidict's core functionality:
from bidict import bidict
element_by_symbol = bidict({'H': 'hydrogen'})
print(element_by_symbol['H'])
print(element_by_symbol.inverse['hydrogen'])Why Use bidict?
bidict stands out for several reasons:
- Mature and Trusted: With over a decade of development, it's a proven solution used by leading companies.
- Pythonic APIs: Designed for safety, simplicity, flexibility, and ergonomics, making it intuitive for Python developers.
- Lightweight: It has no runtime dependencies beyond Python's standard library.
- High Quality Code: Implemented in concise, fully type-hinted Python, optimized for efficiency and long-term stability.
- Extensive Documentation: Comprehensive documentation is available to help you get the most out of the library.
- 100% Test Coverage: Ensures reliability across all supported Python versions, including property-based tests and benchmarks.
Links
For more information, documentation, and to contribute, check out these official links: