ormar-utils 0.2.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.
@@ -0,0 +1,133 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ tags: ["v*"]
7
+ pull_request:
8
+ branches: [main]
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ lint:
15
+ name: Lint (rustfmt, clippy, ruff)
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - name: Install Rust toolchain
20
+ uses: dtolnay/rust-toolchain@stable
21
+ with:
22
+ components: clippy, rustfmt
23
+ - name: Rust format check
24
+ run: cargo fmt --check
25
+ - name: Clippy
26
+ run: cargo clippy --all-targets -- -D warnings
27
+ - uses: actions/setup-python@v5
28
+ with:
29
+ python-version: "3.12"
30
+ - name: Install Ruff
31
+ run: pip install ruff
32
+ - name: Ruff lint
33
+ run: ruff check tests
34
+ - name: Ruff format check
35
+ run: ruff format --check tests
36
+
37
+ test:
38
+ name: Test (py${{ matrix.python-version }} on ${{ matrix.os }})
39
+ needs: lint
40
+ runs-on: ${{ matrix.os }}
41
+ strategy:
42
+ fail-fast: false
43
+ matrix:
44
+ os: [ubuntu-latest, macos-latest, windows-latest]
45
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
46
+ steps:
47
+ - uses: actions/checkout@v4
48
+ - uses: actions/setup-python@v5
49
+ with:
50
+ python-version: ${{ matrix.python-version }}
51
+ - name: Install Rust toolchain
52
+ uses: dtolnay/rust-toolchain@stable
53
+ - name: Install build/test tooling
54
+ run: pip install "maturin>=1.0,<2.0" pytest
55
+ - name: Build abi3 wheel
56
+ run: maturin build --release --out dist
57
+ - name: Install wheel
58
+ run: pip install --no-index --find-links dist ormar-utils
59
+ - name: Run tests
60
+ run: pytest tests/ -v
61
+
62
+ build:
63
+ name: Build wheels (${{ matrix.os }}-${{ matrix.target }})
64
+ needs: test
65
+ if: startsWith(github.ref, 'refs/tags/v')
66
+ runs-on: ${{ matrix.os }}
67
+ strategy:
68
+ matrix:
69
+ include:
70
+ - os: ubuntu-latest
71
+ target: x86_64
72
+ - os: ubuntu-latest
73
+ target: aarch64
74
+ - os: macos-latest
75
+ target: x86_64
76
+ - os: macos-latest
77
+ target: aarch64
78
+ - os: windows-latest
79
+ target: x86_64
80
+ steps:
81
+ - uses: actions/checkout@v4
82
+ - uses: actions/setup-python@v5
83
+ with:
84
+ python-version: "3.12"
85
+ # abi3-py310 produces a single stable-ABI wheel per platform that works on
86
+ # CPython 3.10+ (including future releases), so no per-interpreter matrix.
87
+ - name: Build wheels
88
+ uses: PyO3/maturin-action@v1
89
+ with:
90
+ target: ${{ matrix.target }}
91
+ args: --release --out dist
92
+ manylinux: auto
93
+ - name: Upload wheels
94
+ uses: actions/upload-artifact@v4
95
+ with:
96
+ name: wheels-${{ matrix.os }}-${{ matrix.target }}
97
+ path: dist
98
+
99
+ sdist:
100
+ name: Build sdist
101
+ needs: test
102
+ if: startsWith(github.ref, 'refs/tags/v')
103
+ runs-on: ubuntu-latest
104
+ steps:
105
+ - uses: actions/checkout@v4
106
+ - name: Build sdist
107
+ uses: PyO3/maturin-action@v1
108
+ with:
109
+ command: sdist
110
+ args: --out dist
111
+ - name: Upload sdist
112
+ uses: actions/upload-artifact@v4
113
+ with:
114
+ name: wheels-sdist
115
+ path: dist
116
+
117
+ publish:
118
+ name: Publish to PyPI
119
+ needs: [build, sdist]
120
+ if: startsWith(github.ref, 'refs/tags/v')
121
+ runs-on: ubuntu-latest
122
+ environment: pypi
123
+ permissions:
124
+ id-token: write
125
+ steps:
126
+ - name: Download all wheels
127
+ uses: actions/download-artifact@v4
128
+ with:
129
+ pattern: wheels-*
130
+ merge-multiple: true
131
+ path: dist
132
+ - name: Publish to PyPI
133
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,23 @@
1
+ # Rust
2
+ /target/
3
+
4
+ # Python
5
+ __pycache__/
6
+ *.py[cod]
7
+ *.so
8
+ *.dylib
9
+ *.pyd
10
+ dist/
11
+ *.egg-info/
12
+ .eggs/
13
+ *.whl
14
+
15
+ # IDE
16
+ .idea/
17
+ .vscode/
18
+ *.swp
19
+
20
+ # Environment
21
+ .env
22
+ .venv/
23
+ venv/
@@ -0,0 +1,25 @@
1
+ repos:
2
+ - repo: local
3
+ hooks:
4
+ - id: cargo-fmt
5
+ name: cargo fmt
6
+ entry: cargo fmt --check
7
+ language: system
8
+ types: [rust]
9
+ pass_filenames: false
10
+
11
+ - id: clippy
12
+ name: clippy
13
+ entry: cargo clippy --all-targets -- -D warnings
14
+ language: system
15
+ types: [rust]
16
+ pass_filenames: false
17
+
18
+ - repo: https://github.com/astral-sh/ruff-pre-commit
19
+ rev: v0.15.16
20
+ hooks:
21
+ - id: ruff
22
+ args: [--fix]
23
+ files: ^tests/
24
+ - id: ruff-format
25
+ files: ^tests/
@@ -0,0 +1,271 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "autocfg"
7
+ version = "1.5.0"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
10
+
11
+ [[package]]
12
+ name = "base64"
13
+ version = "0.22.1"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
16
+
17
+ [[package]]
18
+ name = "cfg-if"
19
+ version = "1.0.4"
20
+ source = "registry+https://github.com/rust-lang/crates.io-index"
21
+ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
22
+
23
+ [[package]]
24
+ name = "equivalent"
25
+ version = "1.0.2"
26
+ source = "registry+https://github.com/rust-lang/crates.io-index"
27
+ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
28
+
29
+ [[package]]
30
+ name = "hashbrown"
31
+ version = "0.16.1"
32
+ source = "registry+https://github.com/rust-lang/crates.io-index"
33
+ checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
34
+
35
+ [[package]]
36
+ name = "heck"
37
+ version = "0.5.0"
38
+ source = "registry+https://github.com/rust-lang/crates.io-index"
39
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
40
+
41
+ [[package]]
42
+ name = "indexmap"
43
+ version = "2.13.0"
44
+ source = "registry+https://github.com/rust-lang/crates.io-index"
45
+ checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017"
46
+ dependencies = [
47
+ "equivalent",
48
+ "hashbrown",
49
+ ]
50
+
51
+ [[package]]
52
+ name = "indoc"
53
+ version = "2.0.7"
54
+ source = "registry+https://github.com/rust-lang/crates.io-index"
55
+ checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
56
+ dependencies = [
57
+ "rustversion",
58
+ ]
59
+
60
+ [[package]]
61
+ name = "itoa"
62
+ version = "1.0.17"
63
+ source = "registry+https://github.com/rust-lang/crates.io-index"
64
+ checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
65
+
66
+ [[package]]
67
+ name = "libc"
68
+ version = "0.2.182"
69
+ source = "registry+https://github.com/rust-lang/crates.io-index"
70
+ checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112"
71
+
72
+ [[package]]
73
+ name = "memchr"
74
+ version = "2.8.0"
75
+ source = "registry+https://github.com/rust-lang/crates.io-index"
76
+ checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
77
+
78
+ [[package]]
79
+ name = "memoffset"
80
+ version = "0.9.1"
81
+ source = "registry+https://github.com/rust-lang/crates.io-index"
82
+ checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
83
+ dependencies = [
84
+ "autocfg",
85
+ ]
86
+
87
+ [[package]]
88
+ name = "once_cell"
89
+ version = "1.21.3"
90
+ source = "registry+https://github.com/rust-lang/crates.io-index"
91
+ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
92
+
93
+ [[package]]
94
+ name = "ormar_rust_utils"
95
+ version = "0.2.0"
96
+ dependencies = [
97
+ "base64",
98
+ "indexmap",
99
+ "pyo3",
100
+ "serde_json",
101
+ ]
102
+
103
+ [[package]]
104
+ name = "portable-atomic"
105
+ version = "1.13.1"
106
+ source = "registry+https://github.com/rust-lang/crates.io-index"
107
+ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
108
+
109
+ [[package]]
110
+ name = "proc-macro2"
111
+ version = "1.0.106"
112
+ source = "registry+https://github.com/rust-lang/crates.io-index"
113
+ checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
114
+ dependencies = [
115
+ "unicode-ident",
116
+ ]
117
+
118
+ [[package]]
119
+ name = "pyo3"
120
+ version = "0.23.5"
121
+ source = "registry+https://github.com/rust-lang/crates.io-index"
122
+ checksum = "7778bffd85cf38175ac1f545509665d0b9b92a198ca7941f131f85f7a4f9a872"
123
+ dependencies = [
124
+ "cfg-if",
125
+ "indoc",
126
+ "libc",
127
+ "memoffset",
128
+ "once_cell",
129
+ "portable-atomic",
130
+ "pyo3-build-config",
131
+ "pyo3-ffi",
132
+ "pyo3-macros",
133
+ "unindent",
134
+ ]
135
+
136
+ [[package]]
137
+ name = "pyo3-build-config"
138
+ version = "0.23.5"
139
+ source = "registry+https://github.com/rust-lang/crates.io-index"
140
+ checksum = "94f6cbe86ef3bf18998d9df6e0f3fc1050a8c5efa409bf712e661a4366e010fb"
141
+ dependencies = [
142
+ "once_cell",
143
+ "target-lexicon",
144
+ ]
145
+
146
+ [[package]]
147
+ name = "pyo3-ffi"
148
+ version = "0.23.5"
149
+ source = "registry+https://github.com/rust-lang/crates.io-index"
150
+ checksum = "e9f1b4c431c0bb1c8fb0a338709859eed0d030ff6daa34368d3b152a63dfdd8d"
151
+ dependencies = [
152
+ "libc",
153
+ "pyo3-build-config",
154
+ ]
155
+
156
+ [[package]]
157
+ name = "pyo3-macros"
158
+ version = "0.23.5"
159
+ source = "registry+https://github.com/rust-lang/crates.io-index"
160
+ checksum = "fbc2201328f63c4710f68abdf653c89d8dbc2858b88c5d88b0ff38a75288a9da"
161
+ dependencies = [
162
+ "proc-macro2",
163
+ "pyo3-macros-backend",
164
+ "quote",
165
+ "syn",
166
+ ]
167
+
168
+ [[package]]
169
+ name = "pyo3-macros-backend"
170
+ version = "0.23.5"
171
+ source = "registry+https://github.com/rust-lang/crates.io-index"
172
+ checksum = "fca6726ad0f3da9c9de093d6f116a93c1a38e417ed73bf138472cf4064f72028"
173
+ dependencies = [
174
+ "heck",
175
+ "proc-macro2",
176
+ "pyo3-build-config",
177
+ "quote",
178
+ "syn",
179
+ ]
180
+
181
+ [[package]]
182
+ name = "quote"
183
+ version = "1.0.44"
184
+ source = "registry+https://github.com/rust-lang/crates.io-index"
185
+ checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4"
186
+ dependencies = [
187
+ "proc-macro2",
188
+ ]
189
+
190
+ [[package]]
191
+ name = "rustversion"
192
+ version = "1.0.22"
193
+ source = "registry+https://github.com/rust-lang/crates.io-index"
194
+ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
195
+
196
+ [[package]]
197
+ name = "serde"
198
+ version = "1.0.228"
199
+ source = "registry+https://github.com/rust-lang/crates.io-index"
200
+ checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
201
+ dependencies = [
202
+ "serde_core",
203
+ ]
204
+
205
+ [[package]]
206
+ name = "serde_core"
207
+ version = "1.0.228"
208
+ source = "registry+https://github.com/rust-lang/crates.io-index"
209
+ checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
210
+ dependencies = [
211
+ "serde_derive",
212
+ ]
213
+
214
+ [[package]]
215
+ name = "serde_derive"
216
+ version = "1.0.228"
217
+ source = "registry+https://github.com/rust-lang/crates.io-index"
218
+ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
219
+ dependencies = [
220
+ "proc-macro2",
221
+ "quote",
222
+ "syn",
223
+ ]
224
+
225
+ [[package]]
226
+ name = "serde_json"
227
+ version = "1.0.149"
228
+ source = "registry+https://github.com/rust-lang/crates.io-index"
229
+ checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
230
+ dependencies = [
231
+ "itoa",
232
+ "memchr",
233
+ "serde",
234
+ "serde_core",
235
+ "zmij",
236
+ ]
237
+
238
+ [[package]]
239
+ name = "syn"
240
+ version = "2.0.117"
241
+ source = "registry+https://github.com/rust-lang/crates.io-index"
242
+ checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
243
+ dependencies = [
244
+ "proc-macro2",
245
+ "quote",
246
+ "unicode-ident",
247
+ ]
248
+
249
+ [[package]]
250
+ name = "target-lexicon"
251
+ version = "0.12.16"
252
+ source = "registry+https://github.com/rust-lang/crates.io-index"
253
+ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
254
+
255
+ [[package]]
256
+ name = "unicode-ident"
257
+ version = "1.0.24"
258
+ source = "registry+https://github.com/rust-lang/crates.io-index"
259
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
260
+
261
+ [[package]]
262
+ name = "unindent"
263
+ version = "0.2.4"
264
+ source = "registry+https://github.com/rust-lang/crates.io-index"
265
+ checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
266
+
267
+ [[package]]
268
+ name = "zmij"
269
+ version = "1.0.21"
270
+ source = "registry+https://github.com/rust-lang/crates.io-index"
271
+ checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
@@ -0,0 +1,20 @@
1
+ [package]
2
+ name = "ormar_rust_utils"
3
+ version = "0.2.0"
4
+ edition = "2021"
5
+ description = "Rust-accelerated utility functions for the ormar ORM"
6
+ license = "MIT"
7
+ readme = "README.md"
8
+
9
+ [lib]
10
+ name = "ormar_rust_utils"
11
+ crate-type = ["cdylib"]
12
+
13
+ [dependencies]
14
+ # abi3-py310 builds a single stable-ABI wheel that works on CPython 3.10 and
15
+ # every newer version (3.14, 3.15, ...) without a per-version rebuild, so a new
16
+ # Python release never leaves ormar without an installable wheel.
17
+ pyo3 = { version = "0.23.5", features = ["extension-module", "abi3-py310"] }
18
+ base64 = "0.22"
19
+ serde_json = "1.0"
20
+ indexmap = "2.0"
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Radosław Drążkiewicz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,37 @@
1
+ .PHONY: fmt fmt-check check lint test build clean
2
+
3
+ fmt:
4
+ cargo fmt
5
+ poetry run ruff format tests
6
+
7
+ fmt-check:
8
+ cargo fmt --check
9
+ poetry run ruff format --check tests
10
+
11
+ check:
12
+ cargo clippy --all-targets -- -D warnings
13
+
14
+ lint: fmt-check check
15
+ poetry run ruff check tests
16
+
17
+ test:
18
+ poetry run pytest tests/ -v
19
+
20
+ build:
21
+ poetry run maturin develop
22
+
23
+ clean:
24
+ cargo clean
25
+ rm -rf target/
26
+
27
+ .DEFAULT_GOAL := help
28
+
29
+ help:
30
+ @echo "Available targets:"
31
+ @echo " fmt - Format Rust (rustfmt) and Python (ruff) code"
32
+ @echo " fmt-check - Check formatting without modifying files"
33
+ @echo " check - Run clippy linter with strict warnings"
34
+ @echo " lint - Run all format checks, clippy and ruff lint"
35
+ @echo " test - Run tests with pytest"
36
+ @echo " build - Build the extension module with maturin"
37
+ @echo " clean - Clean build artifacts"
@@ -0,0 +1,82 @@
1
+ Metadata-Version: 2.4
2
+ Name: ormar-utils
3
+ Version: 0.2.0
4
+ Classifier: Development Status :: 4 - Beta
5
+ Classifier: Programming Language :: Rust
6
+ Classifier: Programming Language :: Python :: Implementation :: CPython
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.10
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Topic :: Database
16
+ License-File: LICENSE
17
+ Summary: Rust-accelerated utility functions for the ormar ORM
18
+ Keywords: ormar,orm,rust,performance
19
+ Author-email: Radosław Drążkiewicz <collerek@gmail.com>
20
+ License: MIT
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
23
+ Project-URL: Homepage, https://github.com/ormar-orm/ormar-utils
24
+ Project-URL: Repository, https://github.com/ormar-orm/ormar-utils
25
+
26
+ # ormar-utils
27
+
28
+ Rust-accelerated utility functions for the [ormar](https://github.com/ormar-orm/ormar) async ORM.
29
+
30
+ This package provides optional Rust implementations of performance-critical operations used internally by ormar. When installed, ormar automatically uses these faster implementations.
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install ormar-utils
36
+ ```
37
+
38
+ Or install ormar with the `rust` extra:
39
+
40
+ ```bash
41
+ pip install ormar[rust]
42
+ ```
43
+
44
+ ## Requirements
45
+
46
+ - Python >= 3.10
47
+ - A Rust toolchain (for building from source)
48
+
49
+ Wheels are built against the CPython stable ABI (`abi3`, Python 3.10+), so a
50
+ single wheel per platform works on current and future Python releases without a
51
+ per-version rebuild.
52
+
53
+ ## API Reference
54
+
55
+ All functions are exposed from the `ormar_rust_utils` module:
56
+
57
+ ### Parsers
58
+ - `encode_bytes(value, represent_as_string=False)` - Encode bytes to string (UTF-8 or base64)
59
+ - `decode_bytes(value, represent_as_string=False)` - Decode string to bytes (UTF-8 or base64)
60
+ - `encode_json(value)` - Encode a value to JSON string
61
+
62
+ ### Hashing
63
+ - `hash_item(item)` - Convert a dict/list into a hashable tuple for use as dict key
64
+
65
+ ### List/Dict Utilities
66
+ - `translate_list_to_dict(list_to_trans, default=None)` - Split `__`-separated strings into nested dict
67
+ - `group_related_list(list_)` - Group related strings into nested dictionary
68
+
69
+ ### Collections
70
+ - `UniqueList(initial=None)` - A list that prevents duplicates using hash-based O(1) lookups
71
+
72
+ ### Alias Utilities
73
+ - `build_reverse_alias_map(field_alias_map)` - Build a cached alias -> field_name lookup (with identity entries) from a field_name -> alias mapping
74
+
75
+ ### Merge Infrastructure
76
+ - `group_by_pk(pks)` - Group items by PK hash, preserving insertion order
77
+ - `plan_merge_items_lists(current_pks, other_pks)` - Create a merge plan for two lists by PK
78
+
79
+ ## License
80
+
81
+ MIT
82
+
@@ -0,0 +1,56 @@
1
+ # ormar-utils
2
+
3
+ Rust-accelerated utility functions for the [ormar](https://github.com/ormar-orm/ormar) async ORM.
4
+
5
+ This package provides optional Rust implementations of performance-critical operations used internally by ormar. When installed, ormar automatically uses these faster implementations.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install ormar-utils
11
+ ```
12
+
13
+ Or install ormar with the `rust` extra:
14
+
15
+ ```bash
16
+ pip install ormar[rust]
17
+ ```
18
+
19
+ ## Requirements
20
+
21
+ - Python >= 3.10
22
+ - A Rust toolchain (for building from source)
23
+
24
+ Wheels are built against the CPython stable ABI (`abi3`, Python 3.10+), so a
25
+ single wheel per platform works on current and future Python releases without a
26
+ per-version rebuild.
27
+
28
+ ## API Reference
29
+
30
+ All functions are exposed from the `ormar_rust_utils` module:
31
+
32
+ ### Parsers
33
+ - `encode_bytes(value, represent_as_string=False)` - Encode bytes to string (UTF-8 or base64)
34
+ - `decode_bytes(value, represent_as_string=False)` - Decode string to bytes (UTF-8 or base64)
35
+ - `encode_json(value)` - Encode a value to JSON string
36
+
37
+ ### Hashing
38
+ - `hash_item(item)` - Convert a dict/list into a hashable tuple for use as dict key
39
+
40
+ ### List/Dict Utilities
41
+ - `translate_list_to_dict(list_to_trans, default=None)` - Split `__`-separated strings into nested dict
42
+ - `group_related_list(list_)` - Group related strings into nested dictionary
43
+
44
+ ### Collections
45
+ - `UniqueList(initial=None)` - A list that prevents duplicates using hash-based O(1) lookups
46
+
47
+ ### Alias Utilities
48
+ - `build_reverse_alias_map(field_alias_map)` - Build a cached alias -> field_name lookup (with identity entries) from a field_name -> alias mapping
49
+
50
+ ### Merge Infrastructure
51
+ - `group_by_pk(pks)` - Group items by PK hash, preserving insertion order
52
+ - `plan_merge_items_lists(current_pks, other_pks)` - Create a merge plan for two lists by PK
53
+
54
+ ## License
55
+
56
+ MIT