lastuuid 0.2.1__cp312-cp312-macosx_10_12_x86_64.whl → 0.2.2__cp312-cp312-macosx_10_12_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/dummies.py +43 -1
- lastuuid/lastuuid.cpython-312-darwin.so +0 -0
- lastuuid/utils.py +16 -5
- {lastuuid-0.2.1.dist-info → lastuuid-0.2.2.dist-info}/METADATA +6 -4
- lastuuid-0.2.2.dist-info/RECORD +9 -0
- lastuuid-0.2.1.dist-info/RECORD +0 -9
- {lastuuid-0.2.1.dist-info → lastuuid-0.2.2.dist-info}/WHEEL +0 -0
lastuuid/dummies.py
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""
|
|
2
|
+
A dummy uuid usefull for unit testing purpose.
|
|
3
|
+
|
|
4
|
+
UUID generated here are full of 0, they does not respect any kind of UUID version,
|
|
5
|
+
they remove a bit of cognitive load while testing.
|
|
6
|
+
"""
|
|
2
7
|
|
|
3
8
|
from typing import Iterator
|
|
4
9
|
from uuid import UUID
|
|
@@ -19,6 +24,43 @@ next_id = gen_id()
|
|
|
19
24
|
def uuidgen(i: int = 0, j: int = 0, k: int = 0, x: int = 0, y: int = 0) -> UUID:
|
|
20
25
|
"""
|
|
21
26
|
A UUID generator that makes UUIDs more readable for humans.
|
|
27
|
+
|
|
28
|
+
# Generate autoincrement UUID that you need to predict
|
|
29
|
+
|
|
30
|
+
Sometime you prepare fixtures with well known UUID and you want to repeat them,
|
|
31
|
+
|
|
32
|
+
uuidgen(1) is more readable that UUID('00000001-0000-0000-0000-000000000000'),
|
|
33
|
+
this is why this function is made for.
|
|
34
|
+
Every section of the uuid can be filled out using `i`, `j`, `k`, `x`, `y` but,
|
|
35
|
+
I personnaly never use more than `i` and `j`.
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
>>> from lastuuid.dummies import uuidgen
|
|
39
|
+
>>> uuidgen(1)
|
|
40
|
+
UUID('00000001-0000-0000-0000-000000000000')
|
|
41
|
+
>>> uuidgen(1, 2)
|
|
42
|
+
UUID('00000001-0002-0000-0000-000000000000')
|
|
43
|
+
>>> uuidgen(1, 2, 3, 4, 5)
|
|
44
|
+
UUID('00000001-0002-0003-0004-000000000005')
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```{tip}
|
|
48
|
+
if you don't want a dependency for that, the standard library let you write
|
|
49
|
+
UUID(int=1) which produce UUID('00000000-0000-0000-0000-000000000001').
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
# Generate autoincrement UUID that you don't need to predict
|
|
53
|
+
|
|
54
|
+
Without any parameter, it will generate UUID where the last bits are incremented.
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
>>> from lastuuid.dummies import uuidgen
|
|
58
|
+
>>> uuidgen()
|
|
59
|
+
UUID('00000000-0000-0000-0000-000000000001')
|
|
60
|
+
>>> uuidgen()
|
|
61
|
+
UUID('00000000-0000-0000-0000-000000000002')
|
|
62
|
+
```
|
|
63
|
+
|
|
22
64
|
"""
|
|
23
65
|
if i == 0 and y == 0:
|
|
24
66
|
y = next(next_id)
|
|
Binary file
|
lastuuid/utils.py
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Utilities methods that may be used for database querying purpose.
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
Because UUIDv7 are timestamped ordered and monotonically increasing,
|
|
5
|
+
there are a good solution for generating primary keys.
|
|
6
|
+
|
|
7
|
+
The design of UUIDv7 feet well with the design of BTree.
|
|
8
|
+
|
|
9
|
+
Because they contains a date time, a UUID range can be compute
|
|
6
10
|
in order to retrieve UUIDs generated at a given time.
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
|
|
13
|
+
```{important}
|
|
14
|
+
In a distributed system, relying solely on a datetime or UUIDv7 for sorting
|
|
15
|
+
has limitations.
|
|
16
|
+
While UUIDv7 ensures sequential ordering on a single machine, there is no guarantee
|
|
17
|
+
that a UUIDv7 generated later on one machine will be greater than one generated
|
|
18
|
+
earlier on another machine.
|
|
19
|
+
|
|
20
|
+
This documentation does not cover the book Designing Data-Intensive Applications ;).
|
|
21
|
+
```
|
|
11
22
|
"""
|
|
12
23
|
|
|
13
24
|
from datetime import UTC, date, datetime, time, timedelta
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lastuuid
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Classifier: License :: OSI Approved :: MIT License
|
|
5
5
|
Classifier: Programming Language :: Python :: 3
|
|
6
6
|
Classifier: Programming Language :: Rust
|
|
@@ -35,8 +35,10 @@ Project-URL: Changelog, https://mardiros.github.io/lastuuid/changelog.html
|
|
|
35
35
|
UUID type is awesome, but, at the moment, the UUID type in the standard library
|
|
36
36
|
does not support the uuid7 format.
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
**lastuuid** provide **fast UUIDv7 generation** made by the
|
|
39
|
+
[rust crate uuid7](https://crates.io/crates/uuid7) **compatible with Pydantic**.
|
|
40
|
+
|
|
41
|
+
It has additional features that may helps for testing or inspecting UUIDv7.
|
|
40
42
|
|
|
41
43
|
```{note}
|
|
42
44
|
lastuuid is a developer joke based on the nature of UUIDv7,
|
|
@@ -70,7 +72,7 @@ from pydantic import BaseModel, Field
|
|
|
70
72
|
from lastuuid import uuid7
|
|
71
73
|
|
|
72
74
|
|
|
73
|
-
class
|
|
75
|
+
class Event(BaseModel):
|
|
74
76
|
id: UUID = Field(default_factory=uuid7)
|
|
75
77
|
|
|
76
78
|
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
lastuuid-0.2.2.dist-info/METADATA,sha256=cgW4wG5bSCTox0hUYk6JtHSKJvmATHDsZWYAfK4wMs0,3425
|
|
2
|
+
lastuuid-0.2.2.dist-info/WHEEL,sha256=UikT-0yNSRjFwHTq48Crva23dP51dpEy0cz15Gdw5Lc,106
|
|
3
|
+
lastuuid/lastuuid.pyi,sha256=s-ll8KBbUeUUqQz087pADg3Y3HLnOikty6dpmYC8fMs,340
|
|
4
|
+
lastuuid/__init__.py,sha256=QwhIMAj4P8cB98_6Qj3mUceQXkHtS9G3bNfGrgb-R1w,122
|
|
5
|
+
lastuuid/utils.py,sha256=4770hKz093r6psV4zczXwQKnfCBjS-l_NEnJ3laZpIQ,2834
|
|
6
|
+
lastuuid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
lastuuid/dummies.py,sha256=qXs-fm8oztJ0sUhX9H8If66u5H1JPq6Vx28Dczy5zbc,1883
|
|
8
|
+
lastuuid/lastuuid.cpython-312-darwin.so,sha256=SD423jz-UTJJmycUBLZ0wKI8bEx0zwUnGY4VbVSpkD8,478472
|
|
9
|
+
lastuuid-0.2.2.dist-info/RECORD,,
|
lastuuid-0.2.1.dist-info/RECORD
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
lastuuid-0.2.1.dist-info/METADATA,sha256=L3PIVuRQrjOFjyF-JbNsSRYNYAWdEn49d72veTLBOyY,3363
|
|
2
|
-
lastuuid-0.2.1.dist-info/WHEEL,sha256=UikT-0yNSRjFwHTq48Crva23dP51dpEy0cz15Gdw5Lc,106
|
|
3
|
-
lastuuid/lastuuid.pyi,sha256=s-ll8KBbUeUUqQz087pADg3Y3HLnOikty6dpmYC8fMs,340
|
|
4
|
-
lastuuid/__init__.py,sha256=QwhIMAj4P8cB98_6Qj3mUceQXkHtS9G3bNfGrgb-R1w,122
|
|
5
|
-
lastuuid/utils.py,sha256=PPxM7WYP_Bjy1uXn_dg6rc1GMVEkleh2Z0vjb91XXUo,2538
|
|
6
|
-
lastuuid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
lastuuid/dummies.py,sha256=0YcdycGKVya59RUnBZSlJg49WeYwjxBcVZKEwuflu4E,520
|
|
8
|
-
lastuuid/lastuuid.cpython-312-darwin.so,sha256=2__Io1okYi9MBlfFk7FjbZY2vxwN4XW85vaRNhx4OL8,478472
|
|
9
|
-
lastuuid-0.2.1.dist-info/RECORD,,
|
|
File without changes
|