dynamoxy 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/Cargo.lock +2 -2
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/Cargo.toml +2 -2
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/PKG-INFO +82 -29
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/README.md +81 -28
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/README.md +81 -28
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/backend/memory/mod.rs +148 -69
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/backend/memory/partiql.rs +192 -29
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/backend/memory/tests.rs +109 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/client/tests.rs +179 -1
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/client.rs +224 -27
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/config.rs +1 -1
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/error.rs +27 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/events.rs +1 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/expr/mod.rs +1 -1
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/expr/update.rs +92 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-py/src/client.rs +10 -7
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-py/src/convert.rs +6 -1
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-py/src/errors.rs +18 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/AGENT_GUIDE.md +74 -26
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/__init__.py +2 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/_core.pyi +7 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/_pydantic.py +24 -2
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/_utils.py +42 -1
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/attributes.py +22 -2
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/batch.py +70 -34
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/client.py +32 -2
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/codecs.py +234 -42
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/collection.py +47 -14
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/constraints.py +10 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/errors.py +15 -7
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/events.py +7 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/expressions.py +94 -8
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/models.py +17 -4
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/query.py +235 -60
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/repository.py +455 -102
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/schema.py +62 -19
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/table.py +34 -3
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/testing.py +5 -1
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/transactions.py +8 -1
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/LICENSE +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/Cargo.toml +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/backend/aws/convert.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/backend/aws/errors.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/backend/aws/mod.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/backend/memory/admin.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/backend/memory/batch.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/backend/memory/items.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/backend/memory/query.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/backend/memory/table.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/backend/memory/transact.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/backend/mod.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/expr/ast.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/expr/eval.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/expr/parser.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/expr/projection.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/expr/reserved.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/expr/tests.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/lib.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/metrics.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/retry.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/types/mod.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/types/ops.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/types/schema.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/value/mod.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/value/number.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/src/value/size.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-core/tests/emulator.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-py/Cargo.toml +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-py/src/lib.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/crates/dynamoxy-py/src/runtime.rs +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/pyproject.toml +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/__main__.py +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/middleware.py +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/py.typed +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/results.py +0 -0
- {dynamoxy-0.2.0 → dynamoxy-0.3.0}/python/dynamoxy/telemetry.py +0 -0
|
@@ -670,7 +670,7 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
|
|
|
670
670
|
|
|
671
671
|
[[package]]
|
|
672
672
|
name = "dynamoxy-core"
|
|
673
|
-
version = "0.
|
|
673
|
+
version = "0.3.0"
|
|
674
674
|
dependencies = [
|
|
675
675
|
"async-trait",
|
|
676
676
|
"aws-config",
|
|
@@ -686,7 +686,7 @@ dependencies = [
|
|
|
686
686
|
|
|
687
687
|
[[package]]
|
|
688
688
|
name = "dynamoxy-py"
|
|
689
|
-
version = "0.
|
|
689
|
+
version = "0.3.0"
|
|
690
690
|
dependencies = [
|
|
691
691
|
"dynamoxy-core",
|
|
692
692
|
"parking_lot",
|
|
@@ -4,7 +4,7 @@ members = ["crates/dynamoxy-core", "crates/dynamoxy-py"]
|
|
|
4
4
|
|
|
5
5
|
# The single version of the project: the Python package takes it from the binding crate.
|
|
6
6
|
[workspace.package]
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
edition = "2024"
|
|
9
9
|
rust-version = "1.94"
|
|
10
10
|
license = "MIT"
|
|
@@ -13,7 +13,7 @@ homepage = "https://github.com/kalaspuff/dynamoxy"
|
|
|
13
13
|
authors = ["Carl Oscar Aaro <hello@carloscar.com>"]
|
|
14
14
|
|
|
15
15
|
[workspace.dependencies]
|
|
16
|
-
dynamoxy-core = { path = "crates/dynamoxy-core", version = "0.
|
|
16
|
+
dynamoxy-core = { path = "crates/dynamoxy-core", version = "0.3.0" }
|
|
17
17
|
async-trait = "0.1"
|
|
18
18
|
aws-config = { version = "1.12", features = ["behavior-version-latest"] }
|
|
19
19
|
aws-credential-types = { version = "1.3", features = ["hardcoded-credentials"] }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dynamoxy
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Classifier: Development Status :: 3 - Alpha
|
|
5
5
|
Classifier: Framework :: AsyncIO
|
|
6
6
|
Classifier: Framework :: Pydantic :: 2
|
|
@@ -39,12 +39,16 @@ Project-URL: Homepage, https://github.com/kalaspuff/dynamoxy
|
|
|
39
39
|
Project-URL: Issues, https://github.com/kalaspuff/dynamoxy/issues
|
|
40
40
|
Project-URL: Repository, https://github.com/kalaspuff/dynamoxy
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
<h1>
|
|
43
|
+
<picture>
|
|
44
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/kalaspuff/dynamoxy/main/docs/assets/logo/dynamoxy-dark.svg">
|
|
45
|
+
<img src="https://raw.githubusercontent.com/kalaspuff/dynamoxy/main/docs/assets/logo/dynamoxy.svg" alt="" width="44" height="44" align="absmiddle">
|
|
46
|
+
</picture>
|
|
47
|
+
dynamoxy
|
|
48
|
+
</h1>
|
|
43
49
|
|
|
44
50
|
**A typed, async DynamoDB ORM for Python, with a Rust core.** Declare models with type hints (or
|
|
45
|
-
pydantic)
|
|
46
|
-
cursors, transactions with readable failures, unique constraints, optimistic locking,
|
|
47
|
-
single-table design and an in-memory DynamoDB for tests.
|
|
51
|
+
pydantic) and get validated, atomic DynamoDB access, plus an in-memory DynamoDB for your tests.
|
|
48
52
|
|
|
49
53
|
```python
|
|
50
54
|
import asyncio
|
|
@@ -87,6 +91,41 @@ async def main() -> None:
|
|
|
87
91
|
asyncio.run(main())
|
|
88
92
|
```
|
|
89
93
|
|
|
94
|
+
## Highlights
|
|
95
|
+
|
|
96
|
+
- **Typed end to end.** Fields are values on instances and typed paths on the class
|
|
97
|
+
(`User.visits > 3`). Your type checker catches `User(visits="3")` and `User.visits > "3"`.
|
|
98
|
+
- **Errors that tell you what to fix.** DynamoDB's rules are checked before a request is sent:
|
|
99
|
+
|
|
100
|
+
```text
|
|
101
|
+
ValidationError: the transaction has 120 operations (guard items of unique attributes included); DynamoDB allows 100
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
A refused write raises `ItemAlreadyExistsError`, `VersionConflictError` or
|
|
105
|
+
`UniqueConstraintError`, not a bare `ConditionalCheckFailedException`.
|
|
106
|
+
- **Writes that mean what they say.** `create()` never overwrites, `save()` checks the version,
|
|
107
|
+
`update()` is atomic without a read.
|
|
108
|
+
- **Unique values, timestamps and versions** are maintained for you.
|
|
109
|
+
- **Retries built in**, with backoff and jitter. Nothing fails silently.
|
|
110
|
+
- **An in-memory DynamoDB for tests.** No Docker, no AWS account. It refuses what DynamoDB
|
|
111
|
+
refuses, simulates faults and answers in microseconds:
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
dynamoxy.testing.inject_fault(client, operation="GetItem", error="throttling", times=2)
|
|
115
|
+
with dynamoxy.collect() as usage:
|
|
116
|
+
user = await users.get("u1") # throttled twice, retried
|
|
117
|
+
assert usage.retries == 2
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
- **Observable.** Structured logs and event hooks out of the box; OpenTelemetry spans and metrics
|
|
121
|
+
when you configure it. Item contents are never logged.
|
|
122
|
+
- **Single-table design** with key templates such as `"CUSTOMER#{customer_id}"`.
|
|
123
|
+
- **Fast.** 2.5 to 5 times less client CPU per call than boto3 ([numbers](#performance)).
|
|
124
|
+
- **No required dependencies.** pydantic and OpenTelemetry are optional extras.
|
|
125
|
+
|
|
126
|
+
Also covered: indexes, cursors, batches, transactions, TTL, streams, backups, PartiQL and table
|
|
127
|
+
management.
|
|
128
|
+
|
|
90
129
|
## Already using pydantic?
|
|
91
130
|
|
|
92
131
|
Inherit from `dynamoxy.PydanticModel` instead of `BaseModel` and mark the key. Pydantic keeps
|
|
@@ -123,26 +162,6 @@ A model you would rather not touch can stay as it is: subclass it together with
|
|
|
123
162
|
`dynamoxy.PydanticModel` and re-declare only the fields that need a marker, such as the key (see
|
|
124
163
|
the [pydantic guide](https://github.com/kalaspuff/dynamoxy/blob/main/docs/guides/pydantic.md#existing-models)).
|
|
125
164
|
|
|
126
|
-
## Why dynamoxy
|
|
127
|
-
|
|
128
|
-
- **Typed models**: `Attr[T]` fields are values on instances and typed expression paths on the
|
|
129
|
-
class (`User.visits > 3`); type checkers understand constructors and expressions. Pydantic
|
|
130
|
-
models work too.
|
|
131
|
-
- **Correct by default**: validation before I/O, `create` that never overwrites, optimistic
|
|
132
|
-
locking with `version()`, unique attributes enforced transactionally, automatic timestamps,
|
|
133
|
-
conditions on every write, no values in expression strings.
|
|
134
|
-
- **Every DynamoDB feature**: queries and scans with cursors, global and local indexes,
|
|
135
|
-
batches with unprocessed-item handling, transactions with per-operation cancellation reasons,
|
|
136
|
-
TTL, streams, backups and point-in-time recovery, PartiQL, table management.
|
|
137
|
-
- **Single-table design** with key templates, derived index keys and mixed-entity collections.
|
|
138
|
-
- **Observable**: structured events and logging, hooks, middleware, OpenTelemetry spans and
|
|
139
|
-
metrics, per-request cost accounting (`dynamoxy.collect()`).
|
|
140
|
-
- **Testable**: `dynamoxy.testing.memory_client()` is an in-memory DynamoDB with DynamoDB's
|
|
141
|
-
semantics and fault injection; no Docker, no AWS account.
|
|
142
|
-
- **Fast and robust**: a Rust core (AWS SDK for Rust, Tokio) handles transport, retries with
|
|
143
|
-
backoff, timeouts and batching; wheels for Linux (x86_64, aarch64, glibc and musl), macOS and
|
|
144
|
-
Windows, CPython 3.12+.
|
|
145
|
-
|
|
146
165
|
## Install
|
|
147
166
|
|
|
148
167
|
```bash
|
|
@@ -170,10 +189,44 @@ before writing code with dynamoxy; application repositories can copy the skill i
|
|
|
170
189
|
|
|
171
190
|
## How it works
|
|
172
191
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
192
|
+
A Rust core speaks DynamoDB: the AWS SDK for transport, plus dynamoxy's own retries, batching,
|
|
193
|
+
events and the in-memory backend. Python owns what you touch: models, validation, repositories
|
|
194
|
+
and hooks. A few choices worth knowing:
|
|
195
|
+
|
|
196
|
+
- **Values never go into expression strings**, so reserved words and injection are non-issues.
|
|
197
|
+
- **Unique values are guard items** written in the same transaction, since indexes are only
|
|
198
|
+
eventually consistent.
|
|
199
|
+
- **Models hold no client**, so one model works with several accounts, regions or test stores.
|
|
200
|
+
- **Stored formats are API**: they stay readable across versions.
|
|
201
|
+
|
|
202
|
+
The [architecture](https://github.com/kalaspuff/dynamoxy/blob/main/docs/architecture.md) and the
|
|
203
|
+
[decision records](https://github.com/kalaspuff/dynamoxy/blob/main/docs/adr/README.md) have the
|
|
204
|
+
details.
|
|
205
|
+
|
|
206
|
+
## Performance
|
|
207
|
+
|
|
208
|
+
Round trips cost every client the same. What a library adds is CPU time per call, spent holding
|
|
209
|
+
the GIL. dynamoxy does the protocol work in Rust.
|
|
210
|
+
|
|
211
|
+
Client CPU time per call against a local emulator (dynamoxy returns validated models; the others
|
|
212
|
+
return DynamoDB JSON):
|
|
213
|
+
|
|
214
|
+
| | dynamoxy | boto3 | aiobotocore |
|
|
215
|
+
| --- | ---: | ---: | ---: |
|
|
216
|
+
| `GetItem`, one item | 0.14 ms | 0.66 ms | 0.60 ms |
|
|
217
|
+
| `PutItem`, one item | 0.19 ms | 0.67 ms | 0.61 ms |
|
|
218
|
+
| `Query`, 100 items | 0.65 ms | 1.68 ms | 1.71 ms |
|
|
219
|
+
|
|
220
|
+
- **Cold start** (import and first read): 51 ms, against 115 ms for boto3.
|
|
221
|
+
- **In memory**, a `get()` takes about 13 µs, so large test suites run in seconds.
|
|
222
|
+
|
|
223
|
+
Why it is fast: signing, HTTP, JSON and retries run in Rust outside the GIL; each model plans its
|
|
224
|
+
encoding once, when the class is created; and features you do not use cost nothing.
|
|
225
|
+
|
|
226
|
+
Measured with dynamoxy 0.2.0 on Python 3.14, aarch64 Linux, October 2026. Your hardware will
|
|
227
|
+
differ:
|
|
228
|
+
[`scripts/benchmark.py`](https://github.com/kalaspuff/dynamoxy/blob/main/scripts/benchmark.py)
|
|
229
|
+
measures it on yours.
|
|
177
230
|
|
|
178
231
|
## Contributing
|
|
179
232
|
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
<h1>
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/kalaspuff/dynamoxy/main/docs/assets/logo/dynamoxy-dark.svg">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/kalaspuff/dynamoxy/main/docs/assets/logo/dynamoxy.svg" alt="" width="44" height="44" align="absmiddle">
|
|
5
|
+
</picture>
|
|
6
|
+
dynamoxy
|
|
7
|
+
</h1>
|
|
2
8
|
|
|
3
9
|
**A typed, async DynamoDB ORM for Python, with a Rust core.** Declare models with type hints (or
|
|
4
|
-
pydantic)
|
|
5
|
-
cursors, transactions with readable failures, unique constraints, optimistic locking,
|
|
6
|
-
single-table design and an in-memory DynamoDB for tests.
|
|
10
|
+
pydantic) and get validated, atomic DynamoDB access, plus an in-memory DynamoDB for your tests.
|
|
7
11
|
|
|
8
12
|
```python
|
|
9
13
|
import asyncio
|
|
@@ -46,6 +50,41 @@ async def main() -> None:
|
|
|
46
50
|
asyncio.run(main())
|
|
47
51
|
```
|
|
48
52
|
|
|
53
|
+
## Highlights
|
|
54
|
+
|
|
55
|
+
- **Typed end to end.** Fields are values on instances and typed paths on the class
|
|
56
|
+
(`User.visits > 3`). Your type checker catches `User(visits="3")` and `User.visits > "3"`.
|
|
57
|
+
- **Errors that tell you what to fix.** DynamoDB's rules are checked before a request is sent:
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
ValidationError: the transaction has 120 operations (guard items of unique attributes included); DynamoDB allows 100
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
A refused write raises `ItemAlreadyExistsError`, `VersionConflictError` or
|
|
64
|
+
`UniqueConstraintError`, not a bare `ConditionalCheckFailedException`.
|
|
65
|
+
- **Writes that mean what they say.** `create()` never overwrites, `save()` checks the version,
|
|
66
|
+
`update()` is atomic without a read.
|
|
67
|
+
- **Unique values, timestamps and versions** are maintained for you.
|
|
68
|
+
- **Retries built in**, with backoff and jitter. Nothing fails silently.
|
|
69
|
+
- **An in-memory DynamoDB for tests.** No Docker, no AWS account. It refuses what DynamoDB
|
|
70
|
+
refuses, simulates faults and answers in microseconds:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
dynamoxy.testing.inject_fault(client, operation="GetItem", error="throttling", times=2)
|
|
74
|
+
with dynamoxy.collect() as usage:
|
|
75
|
+
user = await users.get("u1") # throttled twice, retried
|
|
76
|
+
assert usage.retries == 2
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- **Observable.** Structured logs and event hooks out of the box; OpenTelemetry spans and metrics
|
|
80
|
+
when you configure it. Item contents are never logged.
|
|
81
|
+
- **Single-table design** with key templates such as `"CUSTOMER#{customer_id}"`.
|
|
82
|
+
- **Fast.** 2.5 to 5 times less client CPU per call than boto3 ([numbers](#performance)).
|
|
83
|
+
- **No required dependencies.** pydantic and OpenTelemetry are optional extras.
|
|
84
|
+
|
|
85
|
+
Also covered: indexes, cursors, batches, transactions, TTL, streams, backups, PartiQL and table
|
|
86
|
+
management.
|
|
87
|
+
|
|
49
88
|
## Already using pydantic?
|
|
50
89
|
|
|
51
90
|
Inherit from `dynamoxy.PydanticModel` instead of `BaseModel` and mark the key. Pydantic keeps
|
|
@@ -82,26 +121,6 @@ A model you would rather not touch can stay as it is: subclass it together with
|
|
|
82
121
|
`dynamoxy.PydanticModel` and re-declare only the fields that need a marker, such as the key (see
|
|
83
122
|
the [pydantic guide](https://github.com/kalaspuff/dynamoxy/blob/main/docs/guides/pydantic.md#existing-models)).
|
|
84
123
|
|
|
85
|
-
## Why dynamoxy
|
|
86
|
-
|
|
87
|
-
- **Typed models**: `Attr[T]` fields are values on instances and typed expression paths on the
|
|
88
|
-
class (`User.visits > 3`); type checkers understand constructors and expressions. Pydantic
|
|
89
|
-
models work too.
|
|
90
|
-
- **Correct by default**: validation before I/O, `create` that never overwrites, optimistic
|
|
91
|
-
locking with `version()`, unique attributes enforced transactionally, automatic timestamps,
|
|
92
|
-
conditions on every write, no values in expression strings.
|
|
93
|
-
- **Every DynamoDB feature**: queries and scans with cursors, global and local indexes,
|
|
94
|
-
batches with unprocessed-item handling, transactions with per-operation cancellation reasons,
|
|
95
|
-
TTL, streams, backups and point-in-time recovery, PartiQL, table management.
|
|
96
|
-
- **Single-table design** with key templates, derived index keys and mixed-entity collections.
|
|
97
|
-
- **Observable**: structured events and logging, hooks, middleware, OpenTelemetry spans and
|
|
98
|
-
metrics, per-request cost accounting (`dynamoxy.collect()`).
|
|
99
|
-
- **Testable**: `dynamoxy.testing.memory_client()` is an in-memory DynamoDB with DynamoDB's
|
|
100
|
-
semantics and fault injection; no Docker, no AWS account.
|
|
101
|
-
- **Fast and robust**: a Rust core (AWS SDK for Rust, Tokio) handles transport, retries with
|
|
102
|
-
backoff, timeouts and batching; wheels for Linux (x86_64, aarch64, glibc and musl), macOS and
|
|
103
|
-
Windows, CPython 3.12+.
|
|
104
|
-
|
|
105
124
|
## Install
|
|
106
125
|
|
|
107
126
|
```bash
|
|
@@ -129,10 +148,44 @@ before writing code with dynamoxy; application repositories can copy the skill i
|
|
|
129
148
|
|
|
130
149
|
## How it works
|
|
131
150
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
151
|
+
A Rust core speaks DynamoDB: the AWS SDK for transport, plus dynamoxy's own retries, batching,
|
|
152
|
+
events and the in-memory backend. Python owns what you touch: models, validation, repositories
|
|
153
|
+
and hooks. A few choices worth knowing:
|
|
154
|
+
|
|
155
|
+
- **Values never go into expression strings**, so reserved words and injection are non-issues.
|
|
156
|
+
- **Unique values are guard items** written in the same transaction, since indexes are only
|
|
157
|
+
eventually consistent.
|
|
158
|
+
- **Models hold no client**, so one model works with several accounts, regions or test stores.
|
|
159
|
+
- **Stored formats are API**: they stay readable across versions.
|
|
160
|
+
|
|
161
|
+
The [architecture](https://github.com/kalaspuff/dynamoxy/blob/main/docs/architecture.md) and the
|
|
162
|
+
[decision records](https://github.com/kalaspuff/dynamoxy/blob/main/docs/adr/README.md) have the
|
|
163
|
+
details.
|
|
164
|
+
|
|
165
|
+
## Performance
|
|
166
|
+
|
|
167
|
+
Round trips cost every client the same. What a library adds is CPU time per call, spent holding
|
|
168
|
+
the GIL. dynamoxy does the protocol work in Rust.
|
|
169
|
+
|
|
170
|
+
Client CPU time per call against a local emulator (dynamoxy returns validated models; the others
|
|
171
|
+
return DynamoDB JSON):
|
|
172
|
+
|
|
173
|
+
| | dynamoxy | boto3 | aiobotocore |
|
|
174
|
+
| --- | ---: | ---: | ---: |
|
|
175
|
+
| `GetItem`, one item | 0.14 ms | 0.66 ms | 0.60 ms |
|
|
176
|
+
| `PutItem`, one item | 0.19 ms | 0.67 ms | 0.61 ms |
|
|
177
|
+
| `Query`, 100 items | 0.65 ms | 1.68 ms | 1.71 ms |
|
|
178
|
+
|
|
179
|
+
- **Cold start** (import and first read): 51 ms, against 115 ms for boto3.
|
|
180
|
+
- **In memory**, a `get()` takes about 13 µs, so large test suites run in seconds.
|
|
181
|
+
|
|
182
|
+
Why it is fast: signing, HTTP, JSON and retries run in Rust outside the GIL; each model plans its
|
|
183
|
+
encoding once, when the class is created; and features you do not use cost nothing.
|
|
184
|
+
|
|
185
|
+
Measured with dynamoxy 0.2.0 on Python 3.14, aarch64 Linux, October 2026. Your hardware will
|
|
186
|
+
differ:
|
|
187
|
+
[`scripts/benchmark.py`](https://github.com/kalaspuff/dynamoxy/blob/main/scripts/benchmark.py)
|
|
188
|
+
measures it on yours.
|
|
136
189
|
|
|
137
190
|
## Contributing
|
|
138
191
|
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
<h1>
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/kalaspuff/dynamoxy/main/docs/assets/logo/dynamoxy-dark.svg">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/kalaspuff/dynamoxy/main/docs/assets/logo/dynamoxy.svg" alt="" width="44" height="44" align="absmiddle">
|
|
5
|
+
</picture>
|
|
6
|
+
dynamoxy
|
|
7
|
+
</h1>
|
|
2
8
|
|
|
3
9
|
**A typed, async DynamoDB ORM for Python, with a Rust core.** Declare models with type hints (or
|
|
4
|
-
pydantic)
|
|
5
|
-
cursors, transactions with readable failures, unique constraints, optimistic locking,
|
|
6
|
-
single-table design and an in-memory DynamoDB for tests.
|
|
10
|
+
pydantic) and get validated, atomic DynamoDB access, plus an in-memory DynamoDB for your tests.
|
|
7
11
|
|
|
8
12
|
```python
|
|
9
13
|
import asyncio
|
|
@@ -46,6 +50,41 @@ async def main() -> None:
|
|
|
46
50
|
asyncio.run(main())
|
|
47
51
|
```
|
|
48
52
|
|
|
53
|
+
## Highlights
|
|
54
|
+
|
|
55
|
+
- **Typed end to end.** Fields are values on instances and typed paths on the class
|
|
56
|
+
(`User.visits > 3`). Your type checker catches `User(visits="3")` and `User.visits > "3"`.
|
|
57
|
+
- **Errors that tell you what to fix.** DynamoDB's rules are checked before a request is sent:
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
ValidationError: the transaction has 120 operations (guard items of unique attributes included); DynamoDB allows 100
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
A refused write raises `ItemAlreadyExistsError`, `VersionConflictError` or
|
|
64
|
+
`UniqueConstraintError`, not a bare `ConditionalCheckFailedException`.
|
|
65
|
+
- **Writes that mean what they say.** `create()` never overwrites, `save()` checks the version,
|
|
66
|
+
`update()` is atomic without a read.
|
|
67
|
+
- **Unique values, timestamps and versions** are maintained for you.
|
|
68
|
+
- **Retries built in**, with backoff and jitter. Nothing fails silently.
|
|
69
|
+
- **An in-memory DynamoDB for tests.** No Docker, no AWS account. It refuses what DynamoDB
|
|
70
|
+
refuses, simulates faults and answers in microseconds:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
dynamoxy.testing.inject_fault(client, operation="GetItem", error="throttling", times=2)
|
|
74
|
+
with dynamoxy.collect() as usage:
|
|
75
|
+
user = await users.get("u1") # throttled twice, retried
|
|
76
|
+
assert usage.retries == 2
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- **Observable.** Structured logs and event hooks out of the box; OpenTelemetry spans and metrics
|
|
80
|
+
when you configure it. Item contents are never logged.
|
|
81
|
+
- **Single-table design** with key templates such as `"CUSTOMER#{customer_id}"`.
|
|
82
|
+
- **Fast.** 2.5 to 5 times less client CPU per call than boto3 ([numbers](#performance)).
|
|
83
|
+
- **No required dependencies.** pydantic and OpenTelemetry are optional extras.
|
|
84
|
+
|
|
85
|
+
Also covered: indexes, cursors, batches, transactions, TTL, streams, backups, PartiQL and table
|
|
86
|
+
management.
|
|
87
|
+
|
|
49
88
|
## Already using pydantic?
|
|
50
89
|
|
|
51
90
|
Inherit from `dynamoxy.PydanticModel` instead of `BaseModel` and mark the key. Pydantic keeps
|
|
@@ -82,26 +121,6 @@ A model you would rather not touch can stay as it is: subclass it together with
|
|
|
82
121
|
`dynamoxy.PydanticModel` and re-declare only the fields that need a marker, such as the key (see
|
|
83
122
|
the [pydantic guide](https://github.com/kalaspuff/dynamoxy/blob/main/docs/guides/pydantic.md#existing-models)).
|
|
84
123
|
|
|
85
|
-
## Why dynamoxy
|
|
86
|
-
|
|
87
|
-
- **Typed models**: `Attr[T]` fields are values on instances and typed expression paths on the
|
|
88
|
-
class (`User.visits > 3`); type checkers understand constructors and expressions. Pydantic
|
|
89
|
-
models work too.
|
|
90
|
-
- **Correct by default**: validation before I/O, `create` that never overwrites, optimistic
|
|
91
|
-
locking with `version()`, unique attributes enforced transactionally, automatic timestamps,
|
|
92
|
-
conditions on every write, no values in expression strings.
|
|
93
|
-
- **Every DynamoDB feature**: queries and scans with cursors, global and local indexes,
|
|
94
|
-
batches with unprocessed-item handling, transactions with per-operation cancellation reasons,
|
|
95
|
-
TTL, streams, backups and point-in-time recovery, PartiQL, table management.
|
|
96
|
-
- **Single-table design** with key templates, derived index keys and mixed-entity collections.
|
|
97
|
-
- **Observable**: structured events and logging, hooks, middleware, OpenTelemetry spans and
|
|
98
|
-
metrics, per-request cost accounting (`dynamoxy.collect()`).
|
|
99
|
-
- **Testable**: `dynamoxy.testing.memory_client()` is an in-memory DynamoDB with DynamoDB's
|
|
100
|
-
semantics and fault injection; no Docker, no AWS account.
|
|
101
|
-
- **Fast and robust**: a Rust core (AWS SDK for Rust, Tokio) handles transport, retries with
|
|
102
|
-
backoff, timeouts and batching; wheels for Linux (x86_64, aarch64, glibc and musl), macOS and
|
|
103
|
-
Windows, CPython 3.12+.
|
|
104
|
-
|
|
105
124
|
## Install
|
|
106
125
|
|
|
107
126
|
```bash
|
|
@@ -129,10 +148,44 @@ before writing code with dynamoxy; application repositories can copy the skill i
|
|
|
129
148
|
|
|
130
149
|
## How it works
|
|
131
150
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
151
|
+
A Rust core speaks DynamoDB: the AWS SDK for transport, plus dynamoxy's own retries, batching,
|
|
152
|
+
events and the in-memory backend. Python owns what you touch: models, validation, repositories
|
|
153
|
+
and hooks. A few choices worth knowing:
|
|
154
|
+
|
|
155
|
+
- **Values never go into expression strings**, so reserved words and injection are non-issues.
|
|
156
|
+
- **Unique values are guard items** written in the same transaction, since indexes are only
|
|
157
|
+
eventually consistent.
|
|
158
|
+
- **Models hold no client**, so one model works with several accounts, regions or test stores.
|
|
159
|
+
- **Stored formats are API**: they stay readable across versions.
|
|
160
|
+
|
|
161
|
+
The [architecture](https://github.com/kalaspuff/dynamoxy/blob/main/docs/architecture.md) and the
|
|
162
|
+
[decision records](https://github.com/kalaspuff/dynamoxy/blob/main/docs/adr/README.md) have the
|
|
163
|
+
details.
|
|
164
|
+
|
|
165
|
+
## Performance
|
|
166
|
+
|
|
167
|
+
Round trips cost every client the same. What a library adds is CPU time per call, spent holding
|
|
168
|
+
the GIL. dynamoxy does the protocol work in Rust.
|
|
169
|
+
|
|
170
|
+
Client CPU time per call against a local emulator (dynamoxy returns validated models; the others
|
|
171
|
+
return DynamoDB JSON):
|
|
172
|
+
|
|
173
|
+
| | dynamoxy | boto3 | aiobotocore |
|
|
174
|
+
| --- | ---: | ---: | ---: |
|
|
175
|
+
| `GetItem`, one item | 0.14 ms | 0.66 ms | 0.60 ms |
|
|
176
|
+
| `PutItem`, one item | 0.19 ms | 0.67 ms | 0.61 ms |
|
|
177
|
+
| `Query`, 100 items | 0.65 ms | 1.68 ms | 1.71 ms |
|
|
178
|
+
|
|
179
|
+
- **Cold start** (import and first read): 51 ms, against 115 ms for boto3.
|
|
180
|
+
- **In memory**, a `get()` takes about 13 µs, so large test suites run in seconds.
|
|
181
|
+
|
|
182
|
+
Why it is fast: signing, HTTP, JSON and retries run in Rust outside the GIL; each model plans its
|
|
183
|
+
encoding once, when the class is created; and features you do not use cost nothing.
|
|
184
|
+
|
|
185
|
+
Measured with dynamoxy 0.2.0 on Python 3.14, aarch64 Linux, October 2026. Your hardware will
|
|
186
|
+
differ:
|
|
187
|
+
[`scripts/benchmark.py`](https://github.com/kalaspuff/dynamoxy/blob/main/scripts/benchmark.py)
|
|
188
|
+
measures it on yours.
|
|
136
189
|
|
|
137
190
|
## Contributing
|
|
138
191
|
|