# uuid7gen
A lightweight and pure-Python implementation of UUIDv7 for Python versions < 3.11. Fully compatible with [RFC 9562](https://www.rfc-editor.org/rfc/rfc9562.html), including submillisecond precision.
## Installation
```bash
pip install uuid7gen
```
## Usage
### Generate a single UUIDv7 (with optional submillisecond precision)
```python
from uuid7gen import uuid7
id = uuid7()
print(id)
# Example output (ms precision):
# 018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c7c
# Generate with submillisecond precision
timestamp_ms = 1620000000123.456 # float, ms since epoch
id_subms = uuid7(timestamp_ms=timestamp_ms)
print(id_subms)
# Example output (subms precision):
# 018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c7d
```
### Generate a batch of UUIDv7s (supports subms intervals)
```python
from uuid7gen import batch_uuid7
ids = batch_uuid7(5, timestamp_start_ms=1620000000123.0, interval_ms=0.1)
for i, id in enumerate(ids):
print(f"{i+1}: {id}")
# Example output:
# 1: 018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c7c
# 2: 018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c7d
# 3: 018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c7e
# 4: 018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c7f
# 5: 018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c80
```
### Visual representations of a UUIDv7
```python
id = uuid7()
print("standard string:", id)
print("bytes:", id.bytes)
print("hex:", id.hex)
print("int:", id.int)
print("urn:", id.urn)
# Example output:
# standard string: 018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c7c
# bytes: b'\x01\x8en|{|\x7f|\xbf|||||||'
# hex: 018e6e7c7b7c7f7cbf7c7c7c7c7c7c7c7c
# int: 212345678901234567890123456789012345
# urn: urn:uuid:018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c7c
```
---
**Features:**
- RFC 9562 compliant (including submillisecond encoding)
- Python <3.11 compatible
- Batch generation with subms intervals
For more details, see the [documentation](https://github.com/yourname/uuid7gen).
Raw data
{
"_id": null,
"home_page": null,
"name": "uuid7gen",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "uuid, uuid7, identifiers, time-based, python",
"author": "Chowlett2",
"author_email": "Conor Howlett <howlettconor@gmail.com>, Adam Lashley <lashleyaq@gmail.com>, Tyler Blume <t-blume@hotmail.com>",
"download_url": "https://files.pythonhosted.org/packages/85/73/65e3c024b0c278d9af90e4a14abd02bd7d1b95e27e7629231940aef67ebd/uuid7gen-0.1.0.tar.gz",
"platform": null,
"description": "\r\n# uuid7gen\r\n\r\nA lightweight and pure-Python implementation of UUIDv7 for Python versions < 3.11. Fully compatible with [RFC 9562](https://www.rfc-editor.org/rfc/rfc9562.html), including submillisecond precision.\r\n\r\n## Installation\r\n\r\n```bash\r\npip install uuid7gen\r\n```\r\n\r\n## Usage\r\n\r\n\r\n### Generate a single UUIDv7 (with optional submillisecond precision)\r\n\r\n```python\r\nfrom uuid7gen import uuid7\r\n\r\nid = uuid7()\r\nprint(id)\r\n\r\n# Example output (ms precision):\r\n# 018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c7c\r\n\r\n# Generate with submillisecond precision\r\ntimestamp_ms = 1620000000123.456 # float, ms since epoch\r\nid_subms = uuid7(timestamp_ms=timestamp_ms)\r\nprint(id_subms)\r\n\r\n# Example output (subms precision):\r\n# 018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c7d\r\n```\r\n\r\n\r\n### Generate a batch of UUIDv7s (supports subms intervals)\r\n\r\n```python\r\nfrom uuid7gen import batch_uuid7\r\n\r\nids = batch_uuid7(5, timestamp_start_ms=1620000000123.0, interval_ms=0.1)\r\nfor i, id in enumerate(ids):\r\n print(f\"{i+1}: {id}\")\r\n\r\n# Example output:\r\n# 1: 018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c7c\r\n# 2: 018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c7d\r\n# 3: 018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c7e\r\n# 4: 018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c7f\r\n# 5: 018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c80\r\n```\r\n\r\n### Visual representations of a UUIDv7\r\n\r\n```python\r\nid = uuid7()\r\nprint(\"standard string:\", id)\r\nprint(\"bytes:\", id.bytes)\r\nprint(\"hex:\", id.hex)\r\nprint(\"int:\", id.int)\r\nprint(\"urn:\", id.urn)\r\n\r\n# Example output:\r\n# standard string: 018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c7c\r\n# bytes: b'\\x01\\x8en|{|\\x7f|\\xbf|||||||'\r\n# hex: 018e6e7c7b7c7f7cbf7c7c7c7c7c7c7c7c\r\n# int: 212345678901234567890123456789012345\r\n# urn: urn:uuid:018e6e7c-7b7c-7f7c-bf7c-7c7c7c7c7c7c\r\n```\r\n\r\n\r\n---\r\n\r\n**Features:**\r\n- RFC 9562 compliant (including submillisecond encoding)\r\n- Python <3.11 compatible\r\n- Batch generation with subms intervals\r\n\r\nFor more details, see the [documentation](https://github.com/yourname/uuid7gen).\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "UUIDv7 generation for Python <3.11",
"version": "0.1.0",
"project_urls": {
"Bug Tracker": "https://github.com/Chowlett2/uuid7gen/issues",
"Homepage": "https://github.com/Chowlett2/uuid7gen",
"Source": "https://github.com/Chowlett2/uuid7gen"
},
"split_keywords": [
"uuid",
" uuid7",
" identifiers",
" time-based",
" python"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "9f153a0f75ab589f536fa62a5cf6567814360bf27cf2a5006edcf525ee8dd264",
"md5": "01a37930a1a8d5e501fde7ce2cb73d93",
"sha256": "6a17013fc65c08eb413b38d7aec44fb0f8ffb27d3281f46d4bd0933c0fdd03ce"
},
"downloads": -1,
"filename": "uuid7gen-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "01a37930a1a8d5e501fde7ce2cb73d93",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 4582,
"upload_time": "2025-07-31T03:09:14",
"upload_time_iso_8601": "2025-07-31T03:09:14.959957Z",
"url": "https://files.pythonhosted.org/packages/9f/15/3a0f75ab589f536fa62a5cf6567814360bf27cf2a5006edcf525ee8dd264/uuid7gen-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "857365e3c024b0c278d9af90e4a14abd02bd7d1b95e27e7629231940aef67ebd",
"md5": "eaad3062c6c2da07904848bf2cbca6ca",
"sha256": "9ead289983f2c2181214c3530534acc13a0630884976885fd5db090883a738bb"
},
"downloads": -1,
"filename": "uuid7gen-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "eaad3062c6c2da07904848bf2cbca6ca",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 4493,
"upload_time": "2025-07-31T03:09:16",
"upload_time_iso_8601": "2025-07-31T03:09:16.368308Z",
"url": "https://files.pythonhosted.org/packages/85/73/65e3c024b0c278d9af90e4a14abd02bd7d1b95e27e7629231940aef67ebd/uuid7gen-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-31 03:09:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Chowlett2",
"github_project": "uuid7gen",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "uuid7gen"
}