uuid-utils 0.6.1__cp38-cp38-musllinux_1_2_aarch64.whl → 0.8.0__cp38-cp38-musllinux_1_2_aarch64.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 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 (1 through 5, meaningful only
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
- def uuid3(namespace: UUID, name: str) -> UUID:
142
- """Generate a UUID from the MD5 hash of a namespace UUID and a name."""
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
- def uuid5(namespace: UUID, name: str) -> UUID:
150
- """Generate a UUID from the SHA-1 hash of a namespace UUID and a name."""
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(node: _Int | None = None, timestamp: _Int | None = None) -> UUID:
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
@@ -1,31 +1,62 @@
1
- import uuid
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 uuid.UUID(int=uuid_utils.uuid1(node, clock_seq).int)
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 uuid.UUID(int=uuid_utils.uuid3(namespace, name).int)
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 uuid.UUID(int=uuid_utils.uuid4().int)
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 uuid.UUID(int=uuid_utils.uuid5(namespace, name).int)
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 uuid.UUID(int=uuid_utils.uuid6(node, timestamp).int)
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 uuid.UUID(int=uuid_utils.uuid7(timestamp).int)
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 uuid.UUID(bytes=uuid_utils.uuid8(bytes).bytes)
77
+ return UUID(bytes=uuid_utils.uuid8(bytes).bytes)
@@ -1,7 +1,34 @@
1
- from uuid import UUID
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
- def uuid3(namespace: UUID, name: str) -> UUID:
17
- """Generate a UUID from the MD5 hash of a namespace UUID and a name."""
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
- def uuid5(namespace: UUID, name: str) -> UUID:
25
- """Generate a UUID from the SHA-1 hash of a namespace UUID and a name."""
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
1
+ Metadata-Version: 2.3
2
2
  Name: uuid_utils
3
- Version: 0.6.1
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.7
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 V4 in Rust
46
- and also adds draft UUID versions like V6.
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
- | Benchmark | Min | Max | Mean | Min (+) | Max (+) | Mean (+) |
91
- |-----------------|---------|---------|---------|-----------------|-----------------|-----------------|
92
- | UUID V1 | 0.058 | 0.059 | 0.058 | 0.005 (12.0x) | 0.005 (11.9x) | 0.005 (12.0x) |
93
- | UUID V3 | 0.063 | 0.064 | 0.063 | 0.008 (7.9x) | 0.008 (8.1x) | 0.008 (8.0x) |
94
- | UUID V4 | 0.041 | 0.041 | 0.041 | 0.004 (11.1x) | 0.004 (10.8x) | 0.004 (10.9x) |
95
- | UUID V5 | 0.064 | 0.066 | 0.065 | 0.008 (8.1x) | 0.008 (8.1x) | 0.008 (8.1x) |
96
- | UUID from hex | 0.024 | 0.025 | 0.024 | 0.004 (6.7x) | 0.004 (6.6x) | 0.004 (6.6x) |
97
- | UUID from bytes | 0.024 | 0.025 | 0.024 | 0.004 (6.7x) | 0.004 (6.6x) | 0.004 (6.7x) |
98
- | UUID from int | 0.024 | 0.025 | 0.024 | 0.004 (6.6x) | 0.004 (6.7x) | 0.004 (6.6x) |
99
- | UUID from fields | 0.028 | 0.028 | 0.028 | 0.009 (3.1x) | 0.009 (3.1x) | 0.009 (3.1x) |
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=-RjMhxHDFkv6r5Nuo8tOF8K60lh-s7-UBZwq-iK_eT8,106
3
+ uuid_utils-0.8.0.dist-info/license_files/LICENSE.md,sha256=DEf1K0xIS9BMeOfJaVQu6jGv5kT1h_O4qMzOhjUsYEY,1487
4
+ uuid_utils.libs/libgcc_s-60abea67.so.1,sha256=5Ymeh-PwFBkI5B-deNMLyVYu2EYmgIu7iQGitm7d2t4,724137
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-38-aarch64-linux-gnu.so,sha256=mVLesNEfpU0JI4T2PjXQ2oBrlTjjKXeljJNsB2SX72Q,4393769
11
+ uuid_utils-0.8.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: maturin (1.3.1)
2
+ Generator: maturin (1.6.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp38-cp38-musllinux_1_2_aarch64
@@ -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=UgeUxneNW9_mlWZPhhB43lkTVY70Kf5hPdpqMczTUKA,106
3
- uuid_utils-0.6.1.dist-info/license_files/LICENSE.md,sha256=DEf1K0xIS9BMeOfJaVQu6jGv5kT1h_O4qMzOhjUsYEY,1487
4
- uuid_utils.libs/libgcc_s-60abea67.so.1,sha256=5Ymeh-PwFBkI5B-deNMLyVYu2EYmgIu7iQGitm7d2t4,724137
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-38-aarch64-linux-gnu.so,sha256=FT4G_B97FPLE-P8P4iDXPFihLxF8L0Nlh34Op4ZDoc0,5376713
11
- uuid_utils-0.6.1.dist-info/RECORD,,