lastuuid 0.1.1__cp311-none-win32.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 +3 -0
- lastuuid/dummies.py +23 -0
- lastuuid/lastuuid.cp311-win32.pyd +0 -0
- lastuuid/lastuuid.pyi +9 -0
- lastuuid/py.typed +0 -0
- lastuuid-0.1.1.dist-info/METADATA +90 -0
- lastuuid-0.1.1.dist-info/RECORD +8 -0
- lastuuid-0.1.1.dist-info/WHEEL +4 -0
lastuuid/__init__.py
ADDED
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}")
|
|
Binary file
|
lastuuid/lastuuid.pyi
ADDED
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,8 @@
|
|
|
1
|
+
lastuuid-0.1.1.dist-info/METADATA,sha256=TqLj9Q9zoEBzuqcnI1eOXUlQTsF0N-bcK5kmeilc3ss,2530
|
|
2
|
+
lastuuid-0.1.1.dist-info/WHEEL,sha256=Va5ImIkXvhKcffo-7SNH_9kd5U3l6ngzcEl07Fi-uJE,91
|
|
3
|
+
lastuuid/dummies.py,sha256=appIhKdQLL_8Mo5Xb0fzYjBV6w3iJrHZzgk-JNAnej0,520
|
|
4
|
+
lastuuid/lastuuid.pyi,sha256=UWNZIdqlzkbln21QRVGqfOX8sn6FLJUjbG3jlAT22O4,192
|
|
5
|
+
lastuuid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
lastuuid/__init__.py,sha256=GwcZ4cGLHj95prUoK_-Te0TY3gxoLguXp-OEMIJNJzo,52
|
|
7
|
+
lastuuid/lastuuid.cp311-win32.pyd,sha256=AcyIlL4-jctZ2C8NSIFuX0bYJb_GndHanri4n2mKCE0,171520
|
|
8
|
+
lastuuid-0.1.1.dist-info/RECORD,,
|