uuid-utils 0.6.1__cp39-cp39-musllinux_1_2_i686.whl → 0.8.0__cp39-cp39-musllinux_1_2_i686.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 uuid-utils might be problematic. Click here for more details.
- uuid_utils/__init__.pyi +27 -11
- uuid_utils/_uuid_utils.cpython-39-i386-linux-gnu.so +0 -0
- uuid_utils/compat/__init__.py +39 -8
- uuid_utils/compat/__init__.pyi +45 -7
- {uuid_utils-0.6.1.dist-info → uuid_utils-0.8.0.dist-info}/METADATA +36 -17
- uuid_utils-0.8.0.dist-info/RECORD +11 -0
- {uuid_utils-0.6.1.dist-info → uuid_utils-0.8.0.dist-info}/WHEEL +1 -1
- uuid_utils-0.6.1.dist-info/RECORD +0 -11
- {uuid_utils-0.6.1.dist-info → uuid_utils-0.8.0.dist-info}/license_files/LICENSE.md +0 -0
uuid_utils/__init__.pyi
CHANGED
|
@@ -60,12 +60,15 @@ class UUID:
|
|
|
60
60
|
variant the UUID variant (one of the constants RESERVED_NCS,
|
|
61
61
|
RFC_4122, RESERVED_MICROSOFT, or RESERVED_FUTURE)
|
|
62
62
|
|
|
63
|
-
version the UUID version number
|
|
64
|
-
when the variant is RFC_4122)
|
|
63
|
+
version the UUID version number
|
|
65
64
|
|
|
66
65
|
is_safe An enum indicating whether the UUID has been generated in
|
|
67
66
|
a way that is safe for multiprocessing applications, via
|
|
68
67
|
uuid_generate_time_safe(3).
|
|
68
|
+
|
|
69
|
+
timestamp The timestamp of the UUID in milliseconds since epoch.
|
|
70
|
+
Only works for UUID versions 1, 6 and 7,
|
|
71
|
+
otherwise raises ValueError.
|
|
69
72
|
"""
|
|
70
73
|
|
|
71
74
|
def __init__(
|
|
@@ -112,6 +115,7 @@ class UUID:
|
|
|
112
115
|
"""Get UUID timestamp milliseconds since epoch.
|
|
113
116
|
Only works for UUID versions 1, 6 and 7, otherwise raises ValueError."""
|
|
114
117
|
...
|
|
118
|
+
|
|
115
119
|
@property
|
|
116
120
|
def urn(self) -> str: ...
|
|
117
121
|
@property
|
|
@@ -138,31 +142,43 @@ def uuid1(node: _Int | None = None, clock_seq: _Int | None = None) -> UUID:
|
|
|
138
142
|
otherwise a random 14-bit sequence number is chosen."""
|
|
139
143
|
...
|
|
140
144
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
if sys.version_info >= (3, 12):
|
|
146
|
+
def uuid3(namespace: UUID, name: str | bytes) -> UUID:
|
|
147
|
+
"""Generate a UUID from the MD5 hash of a namespace UUID and a name."""
|
|
148
|
+
...
|
|
149
|
+
else:
|
|
150
|
+
def uuid3(namespace: UUID, name: str) -> UUID:
|
|
151
|
+
"""Generate a UUID from the MD5 hash of a namespace UUID and a name."""
|
|
152
|
+
...
|
|
144
153
|
|
|
145
154
|
def uuid4() -> UUID:
|
|
146
155
|
"""Generate a random UUID."""
|
|
147
156
|
...
|
|
148
157
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
158
|
+
if sys.version_info >= (3, 12):
|
|
159
|
+
def uuid5(namespace: UUID, name: str | bytes) -> UUID:
|
|
160
|
+
"""Generate a UUID from the SHA-1 hash of a namespace UUID and a name."""
|
|
161
|
+
...
|
|
162
|
+
else:
|
|
163
|
+
def uuid5(namespace: UUID, name: str) -> UUID:
|
|
164
|
+
"""Generate a UUID from the SHA-1 hash of a namespace UUID and a name."""
|
|
165
|
+
...
|
|
152
166
|
|
|
153
|
-
def uuid6(
|
|
167
|
+
def uuid6(
|
|
168
|
+
node: _Int | None = None, timestamp: _Int | None = None, nanos: _Int | None = None
|
|
169
|
+
) -> UUID:
|
|
154
170
|
"""Generate a version 6 UUID using the given timestamp and a host ID.
|
|
155
171
|
This is similar to version 1 UUIDs,
|
|
156
172
|
except that it is lexicographically sortable by timestamp.
|
|
157
173
|
"""
|
|
158
174
|
...
|
|
159
175
|
|
|
160
|
-
def uuid7(timestamp: _Int | None = None) -> UUID:
|
|
176
|
+
def uuid7(timestamp: _Int | None = None, nanos: _Int | None = None) -> UUID:
|
|
161
177
|
"""Generate a version 7 UUID using a time value and random bytes."""
|
|
162
178
|
...
|
|
163
179
|
|
|
164
180
|
def uuid8(bytes: _Bytes) -> UUID:
|
|
165
|
-
"""Generate a custom UUID comprised almost entirely of user-supplied bytes
|
|
181
|
+
"""Generate a custom UUID comprised almost entirely of user-supplied bytes."""
|
|
166
182
|
...
|
|
167
183
|
|
|
168
184
|
NAMESPACE_DNS: UUID
|
|
Binary file
|
uuid_utils/compat/__init__.py
CHANGED
|
@@ -1,31 +1,62 @@
|
|
|
1
|
-
import
|
|
1
|
+
from uuid import (
|
|
2
|
+
NAMESPACE_DNS,
|
|
3
|
+
NAMESPACE_OID,
|
|
4
|
+
NAMESPACE_URL,
|
|
5
|
+
NAMESPACE_X500,
|
|
6
|
+
RESERVED_FUTURE,
|
|
7
|
+
RESERVED_MICROSOFT,
|
|
8
|
+
RESERVED_NCS,
|
|
9
|
+
RFC_4122,
|
|
10
|
+
UUID,
|
|
11
|
+
getnode,
|
|
12
|
+
)
|
|
2
13
|
|
|
3
14
|
import uuid_utils
|
|
4
15
|
|
|
16
|
+
__all__ = [
|
|
17
|
+
"NAMESPACE_DNS",
|
|
18
|
+
"NAMESPACE_OID",
|
|
19
|
+
"NAMESPACE_URL",
|
|
20
|
+
"NAMESPACE_X500",
|
|
21
|
+
"RESERVED_FUTURE",
|
|
22
|
+
"RESERVED_MICROSOFT",
|
|
23
|
+
"RESERVED_NCS",
|
|
24
|
+
"RFC_4122",
|
|
25
|
+
"UUID",
|
|
26
|
+
"getnode",
|
|
27
|
+
"uuid1",
|
|
28
|
+
"uuid3",
|
|
29
|
+
"uuid4",
|
|
30
|
+
"uuid5",
|
|
31
|
+
"uuid6",
|
|
32
|
+
"uuid7",
|
|
33
|
+
"uuid8",
|
|
34
|
+
]
|
|
35
|
+
|
|
5
36
|
|
|
6
37
|
def uuid1(node=None, clock_seq=None):
|
|
7
38
|
"""Generate a UUID from a host ID, sequence number, and the current time.
|
|
8
39
|
If 'node' is not given, getnode() is used to obtain the hardware
|
|
9
40
|
address. If 'clock_seq' is given, it is used as the sequence number;
|
|
10
41
|
otherwise a random 14-bit sequence number is chosen."""
|
|
11
|
-
return
|
|
42
|
+
return UUID(int=uuid_utils.uuid1(node, clock_seq).int)
|
|
12
43
|
|
|
13
44
|
|
|
14
45
|
def uuid3(namespace, name):
|
|
15
46
|
"""Generate a UUID from the MD5 hash of a namespace UUID and a name."""
|
|
16
47
|
namespace = uuid_utils.UUID(namespace.hex) if namespace else namespace
|
|
17
|
-
return
|
|
48
|
+
return UUID(int=uuid_utils.uuid3(namespace, name).int)
|
|
18
49
|
|
|
19
50
|
|
|
20
51
|
def uuid4():
|
|
21
52
|
"""Generate a random UUID."""
|
|
22
|
-
return
|
|
53
|
+
return UUID(int=uuid_utils.uuid4().int)
|
|
23
54
|
|
|
24
55
|
|
|
25
56
|
def uuid5(namespace, name):
|
|
26
57
|
"""Generate a UUID from the SHA-1 hash of a namespace UUID and a name."""
|
|
27
58
|
namespace = uuid_utils.UUID(namespace.hex) if namespace else namespace
|
|
28
|
-
return
|
|
59
|
+
return UUID(int=uuid_utils.uuid5(namespace, name).int)
|
|
29
60
|
|
|
30
61
|
|
|
31
62
|
def uuid6(node=None, timestamp=None):
|
|
@@ -33,14 +64,14 @@ def uuid6(node=None, timestamp=None):
|
|
|
33
64
|
This is similar to version 1 UUIDs,
|
|
34
65
|
except that it is lexicographically sortable by timestamp.
|
|
35
66
|
"""
|
|
36
|
-
return
|
|
67
|
+
return UUID(int=uuid_utils.uuid6(node, timestamp).int)
|
|
37
68
|
|
|
38
69
|
|
|
39
70
|
def uuid7(timestamp=None):
|
|
40
71
|
"""Generate a version 7 UUID using a time value and random bytes."""
|
|
41
|
-
return
|
|
72
|
+
return UUID(int=uuid_utils.uuid7(timestamp).int)
|
|
42
73
|
|
|
43
74
|
|
|
44
75
|
def uuid8(bytes):
|
|
45
76
|
"""Generate a custom UUID comprised almost entirely of user-supplied bytes.."""
|
|
46
|
-
return
|
|
77
|
+
return UUID(bytes=uuid_utils.uuid8(bytes).bytes)
|
uuid_utils/compat/__init__.pyi
CHANGED
|
@@ -1,7 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
import sys
|
|
2
|
+
from uuid import (
|
|
3
|
+
NAMESPACE_DNS,
|
|
4
|
+
NAMESPACE_OID,
|
|
5
|
+
NAMESPACE_URL,
|
|
6
|
+
NAMESPACE_X500,
|
|
7
|
+
RESERVED_FUTURE,
|
|
8
|
+
RESERVED_MICROSOFT,
|
|
9
|
+
RESERVED_NCS,
|
|
10
|
+
RFC_4122,
|
|
11
|
+
UUID,
|
|
12
|
+
SafeUUID,
|
|
13
|
+
getnode,
|
|
14
|
+
)
|
|
2
15
|
|
|
3
16
|
from typing_extensions import TypeAlias
|
|
4
17
|
|
|
18
|
+
__all__ = [
|
|
19
|
+
"NAMESPACE_DNS",
|
|
20
|
+
"NAMESPACE_OID",
|
|
21
|
+
"NAMESPACE_URL",
|
|
22
|
+
"NAMESPACE_X500",
|
|
23
|
+
"RESERVED_FUTURE",
|
|
24
|
+
"RESERVED_MICROSOFT",
|
|
25
|
+
"RESERVED_NCS",
|
|
26
|
+
"RFC_4122",
|
|
27
|
+
"UUID",
|
|
28
|
+
"SafeUUID",
|
|
29
|
+
"getnode",
|
|
30
|
+
]
|
|
31
|
+
|
|
5
32
|
# Because UUID has properties called int and bytes we need to rename these temporarily.
|
|
6
33
|
_Int: TypeAlias = int
|
|
7
34
|
_Bytes: TypeAlias = bytes
|
|
@@ -13,17 +40,28 @@ def uuid1(node: _Int | None = None, clock_seq: _Int | None = None) -> UUID:
|
|
|
13
40
|
otherwise a random 14-bit sequence number is chosen."""
|
|
14
41
|
...
|
|
15
42
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
43
|
+
if sys.version_info >= (3, 12):
|
|
44
|
+
def uuid3(namespace: UUID, name: str | bytes) -> UUID:
|
|
45
|
+
"""Generate a UUID from the MD5 hash of a namespace UUID and a name."""
|
|
46
|
+
...
|
|
47
|
+
|
|
48
|
+
else:
|
|
49
|
+
def uuid3(namespace: UUID, name: str) -> UUID:
|
|
50
|
+
"""Generate a UUID from the MD5 hash of a namespace UUID and a name."""
|
|
51
|
+
...
|
|
19
52
|
|
|
20
53
|
def uuid4() -> UUID:
|
|
21
54
|
"""Generate a random UUID."""
|
|
22
55
|
...
|
|
23
56
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
57
|
+
if sys.version_info >= (3, 12):
|
|
58
|
+
def uuid5(namespace: UUID, name: str | bytes) -> UUID:
|
|
59
|
+
"""Generate a UUID from the SHA-1 hash of a namespace UUID and a name."""
|
|
60
|
+
...
|
|
61
|
+
else:
|
|
62
|
+
def uuid5(namespace: UUID, name: str) -> UUID:
|
|
63
|
+
"""Generate a UUID from the SHA-1 hash of a namespace UUID and a name."""
|
|
64
|
+
...
|
|
27
65
|
|
|
28
66
|
def uuid6(node: _Int | None = None, timestamp: _Int | None = None) -> UUID:
|
|
29
67
|
"""Generate a version 6 UUID using the given timestamp and a host ID.
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: uuid_utils
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.0
|
|
4
4
|
Classifier: Development Status :: 3 - Alpha
|
|
5
5
|
Classifier: Programming Language :: Python
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
7
7
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
8
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
9
8
|
Classifier: Programming Language :: Python :: 3.8
|
|
10
9
|
Classifier: Programming Language :: Python :: 3.9
|
|
11
10
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -19,7 +18,7 @@ License-File: LICENSE.md
|
|
|
19
18
|
Summary: Drop-in replacement for Python UUID in Rust
|
|
20
19
|
Keywords: rust,uuid
|
|
21
20
|
Author-email: Amin Alaee <me@aminalaee.dev>
|
|
22
|
-
Requires-Python: >=3.
|
|
21
|
+
Requires-Python: >=3.8
|
|
23
22
|
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
24
23
|
Project-URL: Documentation, https://github.com/aminalaee/uuid-utils
|
|
25
24
|
Project-URL: Issues, https://github.com/aminalaee/uuid-utils/issues
|
|
@@ -42,8 +41,8 @@ Python UUID implementation using Rust's UUID library.
|
|
|
42
41
|
This will make `uuid4` function around 10x faster.
|
|
43
42
|
|
|
44
43
|
This package can be a drop-in replacement to the standard library UUID
|
|
45
|
-
which implements existing UUID versions like
|
|
46
|
-
and also adds draft UUID versions like
|
|
44
|
+
which implements existing UUID versions like v4 in Rust
|
|
45
|
+
and also adds draft UUID versions like v6.
|
|
47
46
|
|
|
48
47
|
Avaialble UUID versions:
|
|
49
48
|
|
|
@@ -58,10 +57,15 @@ Avaialble UUID versions:
|
|
|
58
57
|
<sup>Please note that UUID versions 6, 7 and 8 are still in draft RFC.</sup><br>
|
|
59
58
|
|
|
60
59
|
## Installation
|
|
61
|
-
|
|
60
|
+
Using `pip`:
|
|
62
61
|
```shell
|
|
63
62
|
$ pip install uuid-utils
|
|
64
63
|
```
|
|
64
|
+
or, using `conda`:
|
|
65
|
+
|
|
66
|
+
```shell
|
|
67
|
+
$ conda install -c conda-forge uuid-utils
|
|
68
|
+
```
|
|
65
69
|
|
|
66
70
|
## Example
|
|
67
71
|
|
|
@@ -85,18 +89,33 @@ UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d')
|
|
|
85
89
|
UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')
|
|
86
90
|
```
|
|
87
91
|
|
|
92
|
+
## Compatibility
|
|
93
|
+
|
|
94
|
+
In some cases, for example if you are using `Django`, you might need `UUID` instances to be returned
|
|
95
|
+
from the standrad-library `uuid`, not a custom `UUID` class.
|
|
96
|
+
In that case you can use the `uuid_utils.compat` which comes with a performance penalty
|
|
97
|
+
in comparison with the `uuid_utils` default behaviour, but is still faster than the standard-library.
|
|
98
|
+
|
|
99
|
+
```py
|
|
100
|
+
>>> import uuid_utils.compat as uuid
|
|
101
|
+
|
|
102
|
+
>>> # make a random UUID
|
|
103
|
+
>>> uuid.uuid4()
|
|
104
|
+
UUID('ffe95fcc-b818-4aca-a350-e0a35b9de6ec')
|
|
105
|
+
```
|
|
106
|
+
|
|
88
107
|
## Benchmarks
|
|
89
108
|
|
|
90
|
-
|
|
|
91
|
-
|
|
92
|
-
|
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
| UUID from bytes
|
|
98
|
-
|
|
|
99
|
-
| UUID from fields | 0.028
|
|
109
|
+
| Benchmark | Min | Max | Mean | Min (+) | Max (+) | Mean (+) |
|
|
110
|
+
| ---------------- | ----- | ----- | ----- | ------------- | ------------- | ------------- |
|
|
111
|
+
| UUID v1 | 0.058 | 0.059 | 0.058 | 0.005 (12.0x) | 0.005 (11.9x) | 0.005 (12.0x) |
|
|
112
|
+
| UUID v3 | 0.063 | 0.064 | 0.063 | 0.008 (7.9x) | 0.008 (8.1x) | 0.008 (8.0x) |
|
|
113
|
+
| UUID v4 | 0.041 | 0.041 | 0.041 | 0.004 (11.1x) | 0.004 (10.8x) | 0.004 (10.9x) |
|
|
114
|
+
| UUID v5 | 0.064 | 0.066 | 0.065 | 0.008 (8.1x) | 0.008 (8.1x) | 0.008 (8.1x) |
|
|
115
|
+
| UUID from hex | 0.024 | 0.025 | 0.024 | 0.004 (6.7x) | 0.004 (6.6x) | 0.004 (6.6x) |
|
|
116
|
+
| UUID from bytes | 0.024 | 0.025 | 0.024 | 0.004 (6.7x) | 0.004 (6.6x) | 0.004 (6.7x) |
|
|
117
|
+
| UUID from int | 0.024 | 0.025 | 0.024 | 0.004 (6.6x) | 0.004 (6.7x) | 0.004 (6.6x) |
|
|
118
|
+
| UUID from fields | 0.028 | 0.028 | 0.028 | 0.009 (3.1x) | 0.009 (3.1x) | 0.009 (3.1x) |
|
|
100
119
|
|
|
101
120
|
## How to develop locally
|
|
102
121
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
uuid_utils-0.8.0.dist-info/METADATA,sha256=9q-Z0SoccWh0vieNO2iG_B7t6LQdl62q96dfCZCYKLA,4644
|
|
2
|
+
uuid_utils-0.8.0.dist-info/WHEEL,sha256=QIX2hwgA230XTb_l__SBYhsYVWFfXWn1L3_sSDJmK1Q,103
|
|
3
|
+
uuid_utils-0.8.0.dist-info/license_files/LICENSE.md,sha256=DEf1K0xIS9BMeOfJaVQu6jGv5kT1h_O4qMzOhjUsYEY,1487
|
|
4
|
+
uuid_utils.libs/libgcc_s-b5472b99.so.1,sha256=wh8CpjXz9IccAyeERcB7YDEx7NH2jF-PykwOyYNeRRI,453841
|
|
5
|
+
uuid_utils/__init__.py,sha256=teEvYB7oh34wISOjZYdA011-7VdeLKfQGjR615_-lCc,622
|
|
6
|
+
uuid_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
uuid_utils/__init__.pyi,sha256=-Ar3_QVwpdIGtIWW-JuPVCoh-cN26YesW1X6l81WR4g,6627
|
|
8
|
+
uuid_utils/compat/__init__.py,sha256=-pGwZJmEoRzNmqteXXtcbjzO7KO3-xekYT02GjImtmM,2071
|
|
9
|
+
uuid_utils/compat/__init__.pyi,sha256=Qv8zmz1maatMXQ9Q_f9dkm8YUJoj4VaMUll_DR_SyM4,2259
|
|
10
|
+
uuid_utils/_uuid_utils.cpython-39-i386-linux-gnu.so,sha256=HxibavGmCwl86OUVBPAbScq_-bU09GuvSkWbZ3PtTfA,690785
|
|
11
|
+
uuid_utils-0.8.0.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
uuid_utils-0.6.1.dist-info/METADATA,sha256=n2cRIvPyh16fFb-4OMW4g-FRdXcVcV1kwuf-cCFeXNQ,4211
|
|
2
|
-
uuid_utils-0.6.1.dist-info/WHEEL,sha256=8usM4vftbi-OlQxugDy0gJKF3jXdQM04lTObNgBUIyE,103
|
|
3
|
-
uuid_utils-0.6.1.dist-info/license_files/LICENSE.md,sha256=DEf1K0xIS9BMeOfJaVQu6jGv5kT1h_O4qMzOhjUsYEY,1487
|
|
4
|
-
uuid_utils.libs/libgcc_s-b5472b99.so.1,sha256=wh8CpjXz9IccAyeERcB7YDEx7NH2jF-PykwOyYNeRRI,453841
|
|
5
|
-
uuid_utils/compat/__init__.pyi,sha256=msxBDRkxWjdSRFmCeP2O2J6pib2qkJoZEaoC5hcF8X8,1425
|
|
6
|
-
uuid_utils/compat/__init__.py,sha256=ajFZzOqIG4NPov3MOxyX3RoZeORisTJqn6X1H0PWGRY,1617
|
|
7
|
-
uuid_utils/__init__.pyi,sha256=Nyd0LDQeqTqOKkjU4358YbDFbxrqwpPb9hP6aQioVCg,6057
|
|
8
|
-
uuid_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
uuid_utils/__init__.py,sha256=teEvYB7oh34wISOjZYdA011-7VdeLKfQGjR615_-lCc,622
|
|
10
|
-
uuid_utils/_uuid_utils.cpython-39-i386-linux-gnu.so,sha256=Conr9iK1rCFK7SARy9gWZ8ip1BOEICMj_IzQuGcvPzI,4508117
|
|
11
|
-
uuid_utils-0.6.1.dist-info/RECORD,,
|
|
File without changes
|