Provides Dex, a Python container for indexing objects of any type.
Project description
ducks 🦆
Index your Python objects for fast lookup by their attributes.
Install
pip install ducks
Usage
The main container in ducks is called a Dex.
from ducks import Dex
objects = [
{'x': 3, 'y': 'a'},
{'x': 6, 'y': 'b'},
{'x': 9, 'y': 'c'}
]
# Create a Dex containing the objects.
# Index on x and y.
dex = Dex(objects, ['x', 'y'])
# get objects
dex[{
'x': {'>': 4, '<': 8}, # where 4 < x < 8
'y': {'in': ['a', 'b']} # and y is 'a' or 'b'
}]
# result: [{'x': 6, 'y': 'b'}]
- The objects can be any Python type.
- Supports ==, !=, in, not in, <, <=, >, >=.
- Index using dict keys, object attributes, and custom functions.
It's fast
Ducks outperforms other data structures for finding Python objects.
Docs
There's more to ducks than making a Dex of dicts.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ducks-0.4.5.tar.gz
(15.3 kB
view hashes)
Built Distribution
ducks-0.4.5-py3-none-any.whl
(20.4 kB
view hashes)