lastuuid 0.1.1__cp312-cp312-musllinux_1_1_x86_64.whl

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.

Potentially problematic release.


This version of lastuuid might be problematic. Click here for more details.

lastuuid/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ from .lastuuid import uuid7
2
+
3
+ __all__ = ["uuid7"]
lastuuid/dummies.py ADDED
@@ -0,0 +1,23 @@
1
+ """A dummy uuid usefull for unit testing purpose."""
2
+
3
+ from typing import Iterator
4
+ from uuid import UUID
5
+
6
+
7
+ def gen_id() -> Iterator[int]:
8
+ num = 0
9
+ while True:
10
+ num += 1
11
+ yield num
12
+
13
+
14
+ next_id = gen_id()
15
+
16
+
17
+ def uuidgen(i: int = 0, j: int = 0, k: int = 0, x: int = 0, y: int = 0) -> UUID:
18
+ """
19
+ A UUID generator that makes UUIDs more readable for humans.
20
+ """
21
+ if i == 0 and y == 0:
22
+ y = next(next_id)
23
+ return UUID(f"{i:0>8}-{j:0>4}-{k:0>4}-{x:0>4}-{y:0>12}")
lastuuid/lastuuid.pyi ADDED
@@ -0,0 +1,9 @@
1
+ """Pyo3 binding interface definition."""
2
+
3
+ from uuid import UUID
4
+
5
+
6
+ def uuid7() -> UUID:
7
+ """
8
+ Generate an uuid using uuidv7 format, the best format that feet in a BTree.
9
+ """
lastuuid/py.typed ADDED
File without changes
@@ -0,0 +1,90 @@
1
+ Metadata-Version: 2.3
2
+ Name: lastuuid
3
+ Version: 0.1.1
4
+ Classifier: License :: OSI Approved :: MIT License
5
+ Classifier: Programming Language :: Python :: 3
6
+ Classifier: Programming Language :: Rust
7
+ Summary: UUID gen for the python standard library.
8
+ Keywords: environment,substitution,variables
9
+ Author: Guillaume Gauvrit <guillaume@gauvr.it>
10
+ Author-email: Guillaume Gauvrit <guillaume@gauvr.it>
11
+ License: MIT License
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
14
+ Project-URL: Homepage, https://github.com/mardiros/lastuuid
15
+ Project-URL: Documentation, https://github.com/mardiros/lastuuid/blob/main/README.md
16
+ Project-URL: Repository, https://github.com/mardiros/lastuuid.git
17
+ Project-URL: Issues, https://github.com/mardiros/lastuuid/issues
18
+ Project-URL: Changelog, https://github.com/mardiros/lastuuid/blob/main/CHANGELOG.md
19
+
20
+ # lastuuid - yet another uuid library
21
+
22
+ UUID type is awesome, but, at the moment, the UUID type in the standard library
23
+ does not support the uuid7 format.
24
+
25
+ ## Usage
26
+
27
+ ### UUID7
28
+
29
+ ```python
30
+ >>> from lastuuid import uuid7
31
+ >>> uuid7()
32
+ UUID('019316cc-f99a-77b3-89d5-ed8c3cf1f50e')
33
+ ```
34
+
35
+ There is no parameter here, the uuid is generated from the current time.
36
+
37
+ The implementation of uuid7 algorithm is made in the uuid7 rust crate.
38
+
39
+ #### Pydantic
40
+
41
+ This lib has been created because all the other library that implement uuid7
42
+ create there own UUID type, so its not easy to use with pydantic.
43
+
44
+ ```python
45
+ from uuid import UUID
46
+ from pydantic import BaseModel, Field
47
+
48
+ from lastuuid import uuid7
49
+
50
+
51
+ class Dummy(BaseModel):
52
+ id: UUID = Field(default_factory=uuid7)
53
+
54
+ ```
55
+
56
+ #### Performance
57
+
58
+ On my machine the uuid7 is as fast (or slow) as the native uuid4.
59
+
60
+ ```bash
61
+ $ python -m timeit "from lastuuid import uuid7; uuid7()"
62
+ 200000 loops, best of 5: 1.8 usec per loop
63
+
64
+ $ python -m timeit "from uuid import uuid4; uuid4()"
65
+ 200000 loops, best of 5: 1.82 usec per loop
66
+ ```
67
+
68
+ ### Testing with uuid without brain
69
+
70
+ Autoincrement your uuid in a test suite avoid some brain pain.
71
+
72
+ ```python
73
+ >>> from lastuuid.dummies import uuidgen
74
+ >>> uuidgen()
75
+ UUID('00000000-0000-0000-0000-000000000001')
76
+ >>> uuidgen()
77
+ UUID('00000000-0000-0000-0000-000000000002')
78
+ ```
79
+
80
+ Or event more readable;
81
+ UUID predicted, where only the first bytes needs to be read.
82
+
83
+ ```python
84
+ >>> from lastuuid.dummies import uuidgen
85
+ >>> uuidgen(1)
86
+ UUID('00000001-0000-0000-0000-000000000000')
87
+ >>> uuidgen(1,2,3,4,5)
88
+ UUID('00000001-0002-0003-0004-000000000005')
89
+ ```
90
+
@@ -0,0 +1,9 @@
1
+ lastuuid-0.1.1.dist-info/METADATA,sha256=aNObGTSbwFTdlW45XWcGMmRGMnK_5FsEwwHqJEk27kc,2460
2
+ lastuuid-0.1.1.dist-info/WHEEL,sha256=j9zKC0UsZo3G_An5da0oN5YIgEAyxluHakKGIzLZy-8,107
3
+ lastuuid.libs/libgcc_s-1e52349c.so.1,sha256=Ani0u_W_tB8ESsFePO4D2mn2lrgWLhyFdw6RETxBTYM,437537
4
+ lastuuid/__init__.py,sha256=J0y-_0o53066oeP1gXBC2MmmBFj0EeETiskPnY4SqKc,49
5
+ lastuuid/dummies.py,sha256=4ekFj4XZ3LsCUr7dxnnEoQUo8mydox8aso6Vp89V1is,497
6
+ lastuuid/lastuuid.pyi,sha256=PJe_XMTEAMFtsfRfo4HNWHTwPdtMl_hSTQJU6jNIKfY,183
7
+ lastuuid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ lastuuid/lastuuid.cpython-312-x86_64-linux-musl.so,sha256=wwzx167ElcItStwIStSZW_k-IRQqG4zHH-4WDcETpps,506105
9
+ lastuuid-0.1.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.7.4)
3
+ Root-Is-Purelib: false
4
+ Tag: cp312-cp312-musllinux_1_1_x86_64
Binary file