Name | odex JSON |
Version |
0.0.7
JSON |
| download |
home_page | https://github.com/barakalon/odex |
Summary | Python object index for fast, declarative retrieval |
upload_time | 2024-07-21 14:31:24 |
maintainer | None |
docs_url | None |
author | Barak Alon |
requires_python | <4.0,>=3.7 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# odex
Python object index for fast, declarative retrieval
## Install
```
pip install odex
```
## Usage
Odex provides a set-like collection called `IndexedSet`:
```python
from odex import IndexedSet, attr, and_
class X:
def __init__(self, a, b):
self.a = a
self.b = b
iset = IndexedSet(
[
X(a=1, b=4),
X(a=2, b=5),
X(a=2, b=6),
X(a=3, b=7),
],
indexes=["a"]
)
# Filter objects with SQL-like expressions:
iset.filter("a = 2 AND b = 5") == {X(a=2, b=5)}
# Or, using the fluent interface:
iset.filter(
and_(
attr("a").eq(2),
attr("b").eq(5)
)
) == {X(a=2, b=5)}
```
`IndexedSet` maintains indexes on the given attributes. There are three index types:
- `HashIndex` - based on `dict`. Only supports exact value queries (e.g. `a = 1`).
- `SortedDictIndex` - based on [Sorted Containers](https://github.com/grantjenks/python-sortedcontainers). Supports exact value _and_ range queries (e.g. `a > 1`), but has slower updates.
- `InvertedIndex` - based on `dict`, but supports collection attributes and queries like `'foo' IN tags`
When attribute names are given as indexes, the index type will be inferred from the given objects. Otherwise, explicit indexes can be given.
## Related projects
- [sqlglot](https://github.com/tobymao/sqlglot) - odex uses sqlglot for expression parsing
- [ducks](https://github.com/manimino/ducks) - similar project with different tradeoffs
## Benchmarks
See [comparisons.ipynb](benchmarks/comparisons.ipynb) for more.
Raw data
{
"_id": null,
"home_page": "https://github.com/barakalon/odex",
"name": "odex",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.7",
"maintainer_email": null,
"keywords": null,
"author": "Barak Alon",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/8c/0a/007ce4514847e59f45c4aa637be7afbed388695dfbf63665e258ee35c7fe/odex-0.0.7.tar.gz",
"platform": null,
"description": "# odex\n\nPython object index for fast, declarative retrieval\n\n## Install\n\n```\npip install odex\n```\n\n## Usage\n\nOdex provides a set-like collection called `IndexedSet`:\n\n```python\nfrom odex import IndexedSet, attr, and_\n\nclass X:\n def __init__(self, a, b):\n self.a = a\n self.b = b\n\niset = IndexedSet(\n [\n X(a=1, b=4),\n X(a=2, b=5),\n X(a=2, b=6),\n X(a=3, b=7),\n ], \n indexes=[\"a\"]\n)\n\n# Filter objects with SQL-like expressions:\niset.filter(\"a = 2 AND b = 5\") == {X(a=2, b=5)}\n\n# Or, using the fluent interface:\niset.filter(\n and_(\n attr(\"a\").eq(2),\n attr(\"b\").eq(5)\n )\n) == {X(a=2, b=5)}\n```\n\n`IndexedSet` maintains indexes on the given attributes. There are three index types:\n- `HashIndex` - based on `dict`. Only supports exact value queries (e.g. `a = 1`).\n- `SortedDictIndex` - based on [Sorted Containers](https://github.com/grantjenks/python-sortedcontainers). Supports exact value _and_ range queries (e.g. `a > 1`), but has slower updates.\n- `InvertedIndex` - based on `dict`, but supports collection attributes and queries like `'foo' IN tags`\n\nWhen attribute names are given as indexes, the index type will be inferred from the given objects. Otherwise, explicit indexes can be given.\n\n## Related projects\n\n- [sqlglot](https://github.com/tobymao/sqlglot) - odex uses sqlglot for expression parsing\n- [ducks](https://github.com/manimino/ducks) - similar project with different tradeoffs\n\n## Benchmarks\n\nSee [comparisons.ipynb](benchmarks/comparisons.ipynb) for more.\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python object index for fast, declarative retrieval",
"version": "0.0.7",
"project_urls": {
"Homepage": "https://github.com/barakalon/odex"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4b0b372d76cde6f9dd2122a2df67beee1ea1aec5b78fc569021b635830734db3",
"md5": "53b317d772b8969fb28bd88c22491322",
"sha256": "1292d35409f23f0fee5c72f66f0a3d3988a41eaf38f3a46f2c21d08f29b109ca"
},
"downloads": -1,
"filename": "odex-0.0.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "53b317d772b8969fb28bd88c22491322",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.7",
"size": 14731,
"upload_time": "2024-07-21T14:31:22",
"upload_time_iso_8601": "2024-07-21T14:31:22.972597Z",
"url": "https://files.pythonhosted.org/packages/4b/0b/372d76cde6f9dd2122a2df67beee1ea1aec5b78fc569021b635830734db3/odex-0.0.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8c0a007ce4514847e59f45c4aa637be7afbed388695dfbf63665e258ee35c7fe",
"md5": "e0572969f60bfa3796afa4b5b3095f73",
"sha256": "f36a9d06dc18a44723221a615c05b79797237ce711ec08b49279836e7e74d456"
},
"downloads": -1,
"filename": "odex-0.0.7.tar.gz",
"has_sig": false,
"md5_digest": "e0572969f60bfa3796afa4b5b3095f73",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.7",
"size": 12308,
"upload_time": "2024-07-21T14:31:24",
"upload_time_iso_8601": "2024-07-21T14:31:24.056149Z",
"url": "https://files.pythonhosted.org/packages/8c/0a/007ce4514847e59f45c4aa637be7afbed388695dfbf63665e258ee35c7fe/odex-0.0.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-21 14:31:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "barakalon",
"github_project": "odex",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "odex"
}