typeid-python 0.3.5__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,314 @@
1
+ # Created by https://www.toptal.com/developers/gitignore/api/venv,python,visualstudiocode,pycharm
2
+ # Edit at https://www.toptal.com/developers/gitignore?templates=venv,python,visualstudiocode,pycharm
3
+
4
+ ### PyCharm ###
5
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
6
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
7
+
8
+ # User-specific stuff
9
+ .idea/**/workspace.xml
10
+ .idea/**/tasks.xml
11
+ .idea/**/usage.statistics.xml
12
+ .idea/**/dictionaries
13
+ .idea/**/shelf
14
+
15
+ # AWS User-specific
16
+ .idea/**/aws.xml
17
+
18
+ # Generated files
19
+ .idea/**/contentModel.xml
20
+
21
+ # Sensitive or high-churn files
22
+ .idea/**/dataSources/
23
+ .idea/**/dataSources.ids
24
+ .idea/**/dataSources.local.xml
25
+ .idea/**/sqlDataSources.xml
26
+ .idea/**/dynamic.xml
27
+ .idea/**/uiDesigner.xml
28
+ .idea/**/dbnavigator.xml
29
+
30
+ # Gradle
31
+ .idea/**/gradle.xml
32
+ .idea/**/libraries
33
+
34
+ # Gradle and Maven with auto-import
35
+ # When using Gradle or Maven with auto-import, you should exclude module files,
36
+ # since they will be recreated, and may cause churn. Uncomment if using
37
+ # auto-import.
38
+ # .idea/artifacts
39
+ # .idea/compiler.xml
40
+ # .idea/jarRepositories.xml
41
+ # .idea/modules.xml
42
+ # .idea/*.iml
43
+ # .idea/modules
44
+ # *.iml
45
+ # *.ipr
46
+
47
+ # CMake
48
+ cmake-build-*/
49
+
50
+ # Mongo Explorer plugin
51
+ .idea/**/mongoSettings.xml
52
+
53
+ # File-based project format
54
+ *.iws
55
+
56
+ # IntelliJ
57
+ out/
58
+
59
+ # mpeltonen/sbt-idea plugin
60
+ .idea_modules/
61
+
62
+ # JIRA plugin
63
+ atlassian-ide-plugin.xml
64
+
65
+ # Cursive Clojure plugin
66
+ .idea/replstate.xml
67
+
68
+ # SonarLint plugin
69
+ .idea/sonarlint/
70
+
71
+ # Crashlytics plugin (for Android Studio and IntelliJ)
72
+ com_crashlytics_export_strings.xml
73
+ crashlytics.properties
74
+ crashlytics-build.properties
75
+ fabric.properties
76
+
77
+ # Editor-based Rest Client
78
+ .idea/httpRequests
79
+
80
+ # Android studio 3.1+ serialized cache file
81
+ .idea/caches/build_file_checksums.ser
82
+
83
+ ### PyCharm Patch ###
84
+ # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
85
+
86
+ # *.iml
87
+ # modules.xml
88
+ # .idea/misc.xml
89
+ # *.ipr
90
+
91
+ # Sonarlint plugin
92
+ # https://plugins.jetbrains.com/plugin/7973-sonarlint
93
+ .idea/**/sonarlint/
94
+
95
+ # SonarQube Plugin
96
+ # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
97
+ .idea/**/sonarIssues.xml
98
+
99
+ # Markdown Navigator plugin
100
+ # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
101
+ .idea/**/markdown-navigator.xml
102
+ .idea/**/markdown-navigator-enh.xml
103
+ .idea/**/markdown-navigator/
104
+
105
+ # Cache file creation bug
106
+ # See https://youtrack.jetbrains.com/issue/JBR-2257
107
+ .idea/$CACHE_FILE$
108
+
109
+ # CodeStream plugin
110
+ # https://plugins.jetbrains.com/plugin/12206-codestream
111
+ .idea/codestream.xml
112
+
113
+ # Azure Toolkit for IntelliJ plugin
114
+ # https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
115
+ .idea/**/azureSettings.xml
116
+
117
+ ### Python ###
118
+ # Byte-compiled / optimized / DLL files
119
+ __pycache__/
120
+ *.py[cod]
121
+ *$py.class
122
+
123
+ # C extensions
124
+ *.so
125
+
126
+ # Distribution / packaging
127
+ .Python
128
+ build/
129
+ develop-eggs/
130
+ dist/
131
+ downloads/
132
+ eggs/
133
+ .eggs/
134
+ lib/
135
+ lib64/
136
+ parts/
137
+ sdist/
138
+ var/
139
+ wheels/
140
+ share/python-wheels/
141
+ *.egg-info/
142
+ .installed.cfg
143
+ *.egg
144
+ MANIFEST
145
+
146
+ # PyInstaller
147
+ # Usually these files are written by a python script from a template
148
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
149
+ *.manifest
150
+ *.spec
151
+
152
+ # Installer logs
153
+ pip-log.txt
154
+ pip-delete-this-directory.txt
155
+
156
+ # Unit test / coverage reports
157
+ htmlcov/
158
+ .tox/
159
+ .nox/
160
+ .coverage
161
+ .coverage.*
162
+ .cache
163
+ nosetests.xml
164
+ coverage.xml
165
+ *.cover
166
+ *.py,cover
167
+ .hypothesis/
168
+ .pytest_cache/
169
+ cover/
170
+
171
+ # Translations
172
+ *.mo
173
+ *.pot
174
+
175
+ # Django stuff:
176
+ *.log
177
+ local_settings.py
178
+ db.sqlite3
179
+ db.sqlite3-journal
180
+
181
+ # Flask stuff:
182
+ instance/
183
+ .webassets-cache
184
+
185
+ # Scrapy stuff:
186
+ .scrapy
187
+
188
+ # Sphinx documentation
189
+ docs/_build/
190
+
191
+ # PyBuilder
192
+ .pybuilder/
193
+ target/
194
+
195
+ # Jupyter Notebook
196
+ .ipynb_checkpoints
197
+
198
+ # IPython
199
+ profile_default/
200
+ ipython_config.py
201
+
202
+ # pyenv
203
+ # For a library or package, you might want to ignore these files since the code is
204
+ # intended to run in multiple environments; otherwise, check them in:
205
+ # .python-version
206
+
207
+ # pipenv
208
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
209
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
210
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
211
+ # install all needed dependencies.
212
+ #Pipfile.lock
213
+
214
+ # poetry
215
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
216
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
217
+ # commonly ignored for libraries.
218
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
219
+ #poetry.lock
220
+
221
+ # pdm
222
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
223
+ #pdm.lock
224
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
225
+ # in version control.
226
+ # https://pdm.fming.dev/#use-with-ide
227
+ .pdm.toml
228
+
229
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
230
+ __pypackages__/
231
+
232
+ # Celery stuff
233
+ celerybeat-schedule
234
+ celerybeat.pid
235
+
236
+ # SageMath parsed files
237
+ *.sage.py
238
+
239
+ # Environments
240
+ .env
241
+ .venv
242
+ env/
243
+ venv/
244
+ ENV/
245
+ env.bak/
246
+ venv.bak/
247
+
248
+ # Spyder project settings
249
+ .spyderproject
250
+ .spyproject
251
+
252
+ # Rope project settings
253
+ .ropeproject
254
+
255
+ # mkdocs documentation
256
+ /site
257
+
258
+ # mypy
259
+ .mypy_cache/
260
+ .dmypy.json
261
+ dmypy.json
262
+
263
+ # Pyre type checker
264
+ .pyre/
265
+
266
+ # pytype static type analyzer
267
+ .pytype/
268
+
269
+ # Cython debug symbols
270
+ cython_debug/
271
+
272
+ # PyCharm
273
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
274
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
275
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
276
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
277
+ #.idea/
278
+
279
+ ### Python Patch ###
280
+ # Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
281
+ poetry.toml
282
+
283
+ # ruff
284
+ .ruff_cache/
285
+
286
+ ### venv ###
287
+ # Virtualenv
288
+ # http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
289
+ [Bb]in
290
+ [Ii]nclude
291
+ [Ll]ib
292
+ [Ll]ib64
293
+ [Ll]ocal
294
+ [Ss]cripts
295
+ pyvenv.cfg
296
+ pip-selfcheck.json
297
+
298
+ ### VisualStudioCode ###
299
+ .vscode/
300
+
301
+ # Local History for Visual Studio Code
302
+ .history/
303
+
304
+ # Built Visual Studio Code Extensions
305
+ *.vsix
306
+
307
+ ### VisualStudioCode Patch ###
308
+ # Ignore all local history of files
309
+ .history
310
+ .ionide
311
+
312
+ # End of https://www.toptal.com/developers/gitignore/api/venv,python,visualstudiocode,pycharm
313
+
314
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Murad Akhundov
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,247 @@
1
+ Metadata-Version: 2.4
2
+ Name: typeid-python
3
+ Version: 0.3.5
4
+ Summary: Python implementation of TypeIDs: type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs
5
+ Project-URL: Homepage, https://github.com/akhundMurad/typeid-python
6
+ Project-URL: Repository, https://github.com/akhundMurad/typeid-python
7
+ Project-URL: Bug Tracker, https://github.com/akhundMurad/typeid-python/issues
8
+ Author-email: Murad Akhundov <akhundov1murad@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: guid,typeid,uuid,uuid6
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Requires-Python: <4,>=3.10
21
+ Requires-Dist: uuid6<2026.0.0,>=2024.7.10
22
+ Provides-Extra: cli
23
+ Requires-Dist: click; extra == 'cli'
24
+ Provides-Extra: rust
25
+ Requires-Dist: uuid-utils>=0.12.0; extra == 'rust'
26
+ Provides-Extra: yaml
27
+ Requires-Dist: pyyaml; extra == 'yaml'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # TypeID Python
31
+
32
+ [![Run Tests](https://github.com/akhundMurad/typeid-python/actions/workflows/test.yml/badge.svg)](https://github.com/akhundMurad/typeid-python/actions/workflows/test.yml)
33
+ [![PyPI Downloads](https://static.pepy.tech/personalized-badge/typeid-python?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads)](https://pepy.tech/projects/typeid-python)
34
+ [![PyPI - Version](https://img.shields.io/pypi/v/typeid-python?color=green)](https://pypi.org/project/typeid-python/)
35
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/typeid-python?color=green)](https://pypi.org/project/typeid-python/)
36
+
37
+
38
+ A **high-performance Python implementation of [TypeIDs](https://github.com/jetpack-io/typeid)** — type-safe,
39
+ sortable identifiers based on **UUIDv7**.
40
+
41
+ TypeIDs are designed for modern systems where identifiers should be:
42
+
43
+ - globally unique
44
+ - sortable by creation time
45
+ - safe to expose externally
46
+ - easy to reason about in logs, APIs, and databases
47
+
48
+ This library provides a Python package with optional Rust acceleration.
49
+
50
+ ## Key features
51
+
52
+ - ✅ UUIDv7-based, time-sortable identifiers
53
+ - ✅ Type-safe prefixes (`user_`, `order_`, …)
54
+ - ✅ Human-readable and URL-safe
55
+ - ✅ Fast generation & parsing (Rust-accelerated)
56
+ - ✅ CLI tools (`new`, `encode`, `decode`, `explain`)
57
+ - ✅ Schema-based ID explanations (JSON / YAML)
58
+ - ✅ Fully offline, no external services
59
+
60
+ ## Performance
61
+
62
+ TypeID is optimized for **real-world performance**, not just correctness.
63
+
64
+ ### Benchmark summary (mean time)
65
+
66
+ | Operation | Before Rust | Rust + optimizations |
67
+ | --------- | ----------- | -------------------- |
68
+ | Generate | 3.47 µs | **0.70 µs** |
69
+ | Parse | 2.08 µs | **1.30 µs** |
70
+ | Workflow | 5.52 µs | **2.25 µs** |
71
+
72
+ ### Highlights
73
+
74
+ * 🚀 **~5× faster generation**
75
+ * ⚡ **~1.6× faster parsing**
76
+ * 🔁 **~2.5× faster end-to-end workflows**
77
+
78
+ Benchmarks are:
79
+
80
+ * reproducible
81
+ * committed as raw JSON
82
+ * runnable locally via `bench/`
83
+
84
+ See [`Docs: Performance`](https://akhundmurad.github.io/typeid-python/performance/) for details.
85
+
86
+ ## Installation
87
+
88
+ ### Core (pure Python)
89
+
90
+ ```console
91
+ $ pip install typeid-python
92
+ ```
93
+
94
+ ### With Rust acceleration (recommended)
95
+
96
+ ```console
97
+ $ pip install typeid-python[rust]
98
+ ```
99
+
100
+ This enables:
101
+
102
+ * Rust base32 encode/decode
103
+ * `uuid-utils` for fast UUIDv7 generation
104
+
105
+ If Rust is unavailable, TypeID automatically falls back to the pure-Python implementation.
106
+
107
+ ### Other optional extras
108
+
109
+ ```console
110
+ $ pip install typeid-python[yaml] # YAML schema support
111
+ $ pip install typeid-python[cli] # CLI tools
112
+ ```
113
+
114
+ Extras are **strictly optional**.
115
+
116
+ ## Usage
117
+
118
+ ### Basic
119
+
120
+ ```python
121
+ from typeid import TypeID
122
+
123
+ tid = TypeID(prefix="user")
124
+
125
+ assert tid.prefix == "user"
126
+ assert isinstance(tid.suffix, str)
127
+ assert str(tid).startswith("user_")
128
+ ```
129
+
130
+ ### From string
131
+
132
+ ```python
133
+ from typeid import TypeID
134
+
135
+ tid = TypeID.from_string("user_01h45ytscbebyvny4gc8cr8ma2")
136
+ assert tid.prefix == "user"
137
+ ```
138
+
139
+ ### From UUIDv7
140
+
141
+ ```python
142
+ from typeid import TypeID
143
+ from uuid6 import uuid7
144
+
145
+ u = uuid7()
146
+ tid = TypeID.from_uuid(prefix="user", suffix=u)
147
+
148
+ assert tid.uuid.version == 7
149
+ ```
150
+
151
+ ### Typed prefixes
152
+
153
+ ```python
154
+ from typing import Literal
155
+ from typeid import TypeID, typeid_factory
156
+
157
+ UserID = TypeID[Literal["user"]]
158
+ gen_user_id = typeid_factory("user")
159
+
160
+ user_id = gen_user_id()
161
+ ```
162
+
163
+ ## CLI
164
+
165
+ ```console
166
+ $ pip install typeid-python[cli]
167
+ ```
168
+
169
+ Generate:
170
+
171
+ ```console
172
+ $ typeid new -p user
173
+ user_01h2xcejqtf2nbrexx3vqjhp41
174
+ ```
175
+
176
+ Decode:
177
+
178
+ ```console
179
+ $ typeid decode user_01h2xcejqtf2nbrexx3vqjhp41
180
+ uuid: 0188bac7-4afa-78aa-bc3b-bd1eef28d881
181
+ ```
182
+
183
+ Encode:
184
+
185
+ ```console
186
+ $ typeid encode 0188bac7-4afa-78aa-bc3b-bd1eef28d881 --prefix user
187
+ ```
188
+
189
+ ## ✨ `typeid explain` — understand any ID
190
+
191
+ ```console
192
+ $ typeid explain user_01h45ytscbebyvny4gc8cr8ma2
193
+ ```
194
+
195
+ Outputs:
196
+
197
+ ```yaml
198
+ parsed:
199
+ prefix: user
200
+ uuid: 01890bf0-846f-7762-8605-5a3abb40e0e5
201
+ created_at: 2025-03-12T10:41:23Z
202
+ sortable: true
203
+ ```
204
+
205
+ Works **without schema**, fully offline.
206
+
207
+ ## Schema-based explanations
208
+
209
+ Define meaning for prefixes using JSON or YAML.
210
+
211
+ Example (`typeid.schema.json`):
212
+
213
+ ```json
214
+ {
215
+ "schema_version": 1,
216
+ "types": {
217
+ "user": {
218
+ "name": "User",
219
+ "owner_team": "identity-platform",
220
+ "pii": true
221
+ }
222
+ }
223
+ }
224
+ ```
225
+
226
+ Then:
227
+
228
+ ```console
229
+ $ typeid explain user_01h45ytscbebyvny4gc8cr8ma2
230
+ ```
231
+
232
+ Read more here: ["Docs: Explain"](https://akhundmurad.github.io/typeid-python/performance/).
233
+
234
+ ## Design principles
235
+
236
+ * **Non-breaking**: stable APIs
237
+ * **Optional acceleration**: Rust is opt-in
238
+ * **Lazy evaluation**: work is done only when needed
239
+ * **Explainability**: identifiers carry meaning
240
+ * **Transparency**: performance claims are backed by data
241
+
242
+ > Think of TypeID as
243
+ > **UUIDs + semantics + observability — without sacrificing speed**
244
+
245
+ ## License
246
+
247
+ MIT