uuid-kit 2.0.0__tar.gz → 2.0.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: uuid-kit
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: Generate UUID values (v4, v7) with flexible formatting, prefixes, suffixes, and output shape options.
5
5
  Author: Troy Tessalone
6
6
  License: MIT
@@ -8,6 +8,12 @@ Project-URL: Homepage, https://github.com/troytessalone/uuid-kit
8
8
  Project-URL: Issues, https://github.com/troytessalone/uuid-kit/issues
9
9
  Keywords: uuid,uuidv4,uuidv7,generator,utility,formatting,transform,output
10
10
  Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
11
17
  Classifier: License :: OSI Approved :: MIT License
12
18
  Classifier: Operating System :: OS Independent
13
19
  Requires-Python: >=3.8
@@ -18,7 +24,7 @@ Dynamic: license-file
18
24
 
19
25
  # uuid-kit
20
26
 
21
- Generate UUID values (v4, v7) with flexible formatting, prefixes, suffixes, and output shape options.
27
+ Generate UUID values (`v4`, `v7`) with flexible formatting, prefixes, suffixes, and output shape options.
22
28
 
23
29
  ---
24
30
 
@@ -168,7 +174,7 @@ Example output:
168
174
  "raw": "123e4567-e89b-12d3-a456-426614174001",
169
175
  "index": 1,
170
176
  "timestamp": {
171
- "iso": "2026-04-09T18:00:00Z",
177
+ "iso": "2026-04-09T18:00:00.001000Z",
172
178
  "unix": 1775757600001
173
179
  }
174
180
  }
@@ -190,7 +196,7 @@ Example output:
190
196
  "format": "standard",
191
197
  "output_as": "string",
192
198
  "count": 3,
193
- "items": "uuid-1,uuid-2,uuid-3"
199
+ "items": "uuid-1\nuuid-2\nuuid-3"
194
200
  }
195
201
  ```
196
202
 
@@ -211,18 +217,18 @@ Each object includes:
211
217
  - `uuid` = final formatted value
212
218
  - `raw` = original UUID before formatting
213
219
  - `index` = zero-based position in the result set
214
- - `timestamp` = only for v7, derived from the UUID
220
+ - `timestamp` = only included for `v7` when `outputAs="object"`
215
221
 
216
222
  ### `outputAs="string"`
217
223
 
218
- Returns `items` as a single comma-delimited string.
224
+ Returns `items` as a single newline-delimited string.
219
225
 
220
226
  ---
221
227
 
222
228
  ## Supported Versions
223
229
 
224
230
  - `v4` = random
225
- - `v7` = modern time-based
231
+ - `v7` = time-based, sortable, recommended
226
232
 
227
233
  ---
228
234
 
@@ -235,6 +241,29 @@ from uuid_kit import ALLOWED_FORMATS, ALLOWED_VERSIONS, ALLOWED_OUTPUT_AS
235
241
 
236
242
  ---
237
243
 
244
+ ## Behavior
245
+
246
+ - Invalid or missing `count` defaults to `1`
247
+ - `count` is capped at `100`
248
+ - `count` is converted to an integer
249
+ - Invalid or missing `version` defaults to `v7`
250
+ - Invalid or missing `format` defaults to `standard`
251
+ - Invalid or missing `outputAs` defaults to `array`
252
+
253
+ ---
254
+
255
+ ## Performance Notes
256
+
257
+ `uuid-kit` avoids unnecessary work during generation:
258
+
259
+ - Object records are only built when `outputAs="object"`
260
+ - Timestamps are only extracted for `v7` object output
261
+ - List storage is preallocated for efficient generation
262
+
263
+ This keeps array and string output paths lighter and faster.
264
+
265
+ ---
266
+
238
267
  ## Environment Notes
239
268
 
240
269
  Some hosted Python runtimes require you to explicitly add packages before use. In those environments, add:
@@ -246,16 +275,6 @@ uuid6
246
275
 
247
276
  ---
248
277
 
249
- ## Behavior
250
-
251
- - Invalid or missing `count` defaults to `1`
252
- - `count` is capped at `100`
253
- - Invalid or missing `version` defaults to `v7`
254
- - Invalid or missing `format` defaults to `standard`
255
- - Invalid or missing `outputAs` defaults to `array`
256
-
257
- ---
258
-
259
278
  ## Notes
260
279
 
261
280
  - Python standard library does not yet include native UUID v7 support
@@ -1,6 +1,6 @@
1
1
  # uuid-kit
2
2
 
3
- Generate UUID values (v4, v7) with flexible formatting, prefixes, suffixes, and output shape options.
3
+ Generate UUID values (`v4`, `v7`) with flexible formatting, prefixes, suffixes, and output shape options.
4
4
 
5
5
  ---
6
6
 
@@ -150,7 +150,7 @@ Example output:
150
150
  "raw": "123e4567-e89b-12d3-a456-426614174001",
151
151
  "index": 1,
152
152
  "timestamp": {
153
- "iso": "2026-04-09T18:00:00Z",
153
+ "iso": "2026-04-09T18:00:00.001000Z",
154
154
  "unix": 1775757600001
155
155
  }
156
156
  }
@@ -172,7 +172,7 @@ Example output:
172
172
  "format": "standard",
173
173
  "output_as": "string",
174
174
  "count": 3,
175
- "items": "uuid-1,uuid-2,uuid-3"
175
+ "items": "uuid-1\nuuid-2\nuuid-3"
176
176
  }
177
177
  ```
178
178
 
@@ -193,18 +193,18 @@ Each object includes:
193
193
  - `uuid` = final formatted value
194
194
  - `raw` = original UUID before formatting
195
195
  - `index` = zero-based position in the result set
196
- - `timestamp` = only for v7, derived from the UUID
196
+ - `timestamp` = only included for `v7` when `outputAs="object"`
197
197
 
198
198
  ### `outputAs="string"`
199
199
 
200
- Returns `items` as a single comma-delimited string.
200
+ Returns `items` as a single newline-delimited string.
201
201
 
202
202
  ---
203
203
 
204
204
  ## Supported Versions
205
205
 
206
206
  - `v4` = random
207
- - `v7` = modern time-based
207
+ - `v7` = time-based, sortable, recommended
208
208
 
209
209
  ---
210
210
 
@@ -217,6 +217,29 @@ from uuid_kit import ALLOWED_FORMATS, ALLOWED_VERSIONS, ALLOWED_OUTPUT_AS
217
217
 
218
218
  ---
219
219
 
220
+ ## Behavior
221
+
222
+ - Invalid or missing `count` defaults to `1`
223
+ - `count` is capped at `100`
224
+ - `count` is converted to an integer
225
+ - Invalid or missing `version` defaults to `v7`
226
+ - Invalid or missing `format` defaults to `standard`
227
+ - Invalid or missing `outputAs` defaults to `array`
228
+
229
+ ---
230
+
231
+ ## Performance Notes
232
+
233
+ `uuid-kit` avoids unnecessary work during generation:
234
+
235
+ - Object records are only built when `outputAs="object"`
236
+ - Timestamps are only extracted for `v7` object output
237
+ - List storage is preallocated for efficient generation
238
+
239
+ This keeps array and string output paths lighter and faster.
240
+
241
+ ---
242
+
220
243
  ## Environment Notes
221
244
 
222
245
  Some hosted Python runtimes require you to explicitly add packages before use. In those environments, add:
@@ -228,16 +251,6 @@ uuid6
228
251
 
229
252
  ---
230
253
 
231
- ## Behavior
232
-
233
- - Invalid or missing `count` defaults to `1`
234
- - `count` is capped at `100`
235
- - Invalid or missing `version` defaults to `v7`
236
- - Invalid or missing `format` defaults to `standard`
237
- - Invalid or missing `outputAs` defaults to `array`
238
-
239
- ---
240
-
241
254
  ## Notes
242
255
 
243
256
  - Python standard library does not yet include native UUID v7 support
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "uuid-kit"
7
- version = "2.0.0"
7
+ version = "2.0.2"
8
8
  description = "Generate UUID values (v4, v7) with flexible formatting, prefixes, suffixes, and output shape options."
9
9
  readme = "README.md"
10
10
  authors = [
@@ -27,10 +27,19 @@ keywords = [
27
27
 
28
28
  classifiers = [
29
29
  "Programming Language :: Python :: 3",
30
+ "Programming Language :: Python :: 3 :: Only",
31
+ "Programming Language :: Python :: 3.8",
32
+ "Programming Language :: Python :: 3.9",
33
+ "Programming Language :: Python :: 3.10",
34
+ "Programming Language :: Python :: 3.11",
35
+ "Programming Language :: Python :: 3.12",
30
36
  "License :: OSI Approved :: MIT License",
31
37
  "Operating System :: OS Independent"
32
38
  ]
33
39
 
34
40
  [project.urls]
35
41
  Homepage = "https://github.com/troytessalone/uuid-kit"
36
- Issues = "https://github.com/troytessalone/uuid-kit/issues"
42
+ Issues = "https://github.com/troytessalone/uuid-kit/issues"
43
+
44
+ [tool.setuptools.package-data]
45
+ uuid_kit = ["py.typed"]
@@ -2,6 +2,7 @@
2
2
 
3
3
  import importlib
4
4
  import uuid
5
+ from datetime import datetime, timezone
5
6
 
6
7
  _uuid7_fn = None
7
8
 
@@ -32,22 +33,19 @@ ALLOWED_OUTPUT_AS = (
32
33
  )
33
34
 
34
35
 
35
- def get_formatter(format_value):
36
- if format_value == "compact":
37
- return lambda v: v.replace("-", "")
38
- if format_value == "uppercase":
39
- return lambda v: v.upper()
40
- if format_value == "uppercase-compact":
41
- return lambda v: v.replace("-", "").upper()
42
- return lambda v: v
36
+ def _generate_v4():
37
+ return str(uuid.uuid4())
38
+
39
+
40
+ def _generate_v7():
41
+ if HAS_UUID7 and _uuid7_fn:
42
+ return str(_uuid7_fn())
43
+ return str(uuid.uuid4())
43
44
 
44
45
 
45
46
  def extract_timestamp_v7(uuid_value):
46
47
  hex_value = uuid_value.replace("-", "")[:12]
47
48
  ms = int(hex_value, 16)
48
-
49
- from datetime import datetime, timezone
50
-
51
49
  dt = datetime.fromtimestamp(ms / 1000, tz=timezone.utc)
52
50
 
53
51
  return {
@@ -56,6 +54,20 @@ def extract_timestamp_v7(uuid_value):
56
54
  }
57
55
 
58
56
 
57
+ VERSION_CONFIG = {
58
+ "v4": {
59
+ "generator": _generate_v4,
60
+ "hasTimestamp": False,
61
+ "extractTimestamp": None
62
+ },
63
+ "v7": {
64
+ "generator": _generate_v7,
65
+ "hasTimestamp": True,
66
+ "extractTimestamp": extract_timestamp_v7
67
+ }
68
+ }
69
+
70
+
59
71
  def generate_uuid(
60
72
  count=1,
61
73
  version="v7",
@@ -109,71 +121,51 @@ def generate_uuid(
109
121
  normalized_output_as = str(outputAs or "array").lower()
110
122
  final_output_as = normalized_output_as if normalized_output_as in ALLOWED_OUTPUT_AS else "array"
111
123
 
112
- formatter = get_formatter(final_format)
124
+ generator = VERSION_CONFIG[final_version]["generator"]
125
+ has_timestamp = VERSION_CONFIG[final_version]["hasTimestamp"]
126
+ extract_timestamp = VERSION_CONFIG[final_version]["extractTimestamp"]
113
127
 
114
- # ===============================
115
- # VERSION CONFIG
116
- # ===============================
117
- def generate_v4():
118
- return str(uuid.uuid4())
119
-
120
- def generate_v7():
121
- if HAS_UUID7 and _uuid7_fn:
122
- return str(_uuid7_fn())
123
- return str(uuid.uuid4())
124
-
125
- version_config = {
126
- "v4": {
127
- "generator": generate_v4,
128
- "hasTimestamp": False,
129
- "extractTimestamp": None
130
- },
131
- "v7": {
132
- "generator": generate_v7,
133
- "hasTimestamp": True,
134
- "extractTimestamp": extract_timestamp_v7
135
- }
136
- }
137
-
138
- generator = version_config[final_version]["generator"]
139
- has_timestamp = version_config[final_version]["hasTimestamp"]
140
- extract_timestamp = version_config[final_version]["extractTimestamp"]
128
+ # Precompute format and affix behavior for the hot loop.
129
+ use_compact = final_format in ("compact", "uppercase-compact")
130
+ use_upper = final_format in ("uppercase", "uppercase-compact")
131
+ prefix_str = str(prefix) if prefix else ""
132
+ suffix_str = str(suffix) if suffix else ""
141
133
 
142
134
  # ===============================
143
- # GENERATE
135
+ # GENERATE (optimized)
144
136
  # ===============================
145
- values = []
146
- objects = []
137
+ needs_object = final_output_as == "object"
138
+
139
+ values = None if needs_object else [None] * safe_count
140
+ objects = [None] * safe_count if needs_object else None
147
141
 
148
142
  for i in range(safe_count):
149
143
  raw = generator()
150
-
151
- timestamp = None
152
- if has_timestamp and extract_timestamp:
153
- try:
154
- timestamp = extract_timestamp(raw)
155
- except Exception:
156
- timestamp = None
157
-
158
- value = formatter(raw)
159
-
160
- if prefix:
161
- value = str(prefix) + value
162
- if suffix:
163
- value = value + str(suffix)
164
-
165
- values.append(value)
166
-
167
- obj = {
168
- "uuid": value,
169
- "raw": raw,
170
- "index": i
171
- }
172
-
173
- if timestamp:
174
- obj["timestamp"] = timestamp
175
-
176
- objects.append(obj)
144
+ value = raw
145
+
146
+ if use_compact:
147
+ value = value.replace("-", "")
148
+ if use_upper:
149
+ value = value.upper()
150
+ if prefix_str or suffix_str:
151
+ value = prefix_str + value + suffix_str
152
+
153
+ if needs_object:
154
+ obj = {
155
+ "uuid": value,
156
+ "raw": raw,
157
+ "index": i
158
+ }
159
+
160
+ if has_timestamp and extract_timestamp:
161
+ try:
162
+ obj["timestamp"] = extract_timestamp(raw)
163
+ except Exception:
164
+ pass
165
+
166
+ objects[i] = obj
167
+ else:
168
+ values[i] = value
177
169
 
178
170
  # ===============================
179
171
  # SHAPE OUTPUT
@@ -181,7 +173,7 @@ def generate_uuid(
181
173
  if final_output_as == "object":
182
174
  items = objects
183
175
  elif final_output_as == "string":
184
- items = ",".join(values)
176
+ items = "\n".join(values)
185
177
  else:
186
178
  items = values
187
179
 
@@ -0,0 +1 @@
1
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: uuid-kit
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: Generate UUID values (v4, v7) with flexible formatting, prefixes, suffixes, and output shape options.
5
5
  Author: Troy Tessalone
6
6
  License: MIT
@@ -8,6 +8,12 @@ Project-URL: Homepage, https://github.com/troytessalone/uuid-kit
8
8
  Project-URL: Issues, https://github.com/troytessalone/uuid-kit/issues
9
9
  Keywords: uuid,uuidv4,uuidv7,generator,utility,formatting,transform,output
10
10
  Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
11
17
  Classifier: License :: OSI Approved :: MIT License
12
18
  Classifier: Operating System :: OS Independent
13
19
  Requires-Python: >=3.8
@@ -18,7 +24,7 @@ Dynamic: license-file
18
24
 
19
25
  # uuid-kit
20
26
 
21
- Generate UUID values (v4, v7) with flexible formatting, prefixes, suffixes, and output shape options.
27
+ Generate UUID values (`v4`, `v7`) with flexible formatting, prefixes, suffixes, and output shape options.
22
28
 
23
29
  ---
24
30
 
@@ -168,7 +174,7 @@ Example output:
168
174
  "raw": "123e4567-e89b-12d3-a456-426614174001",
169
175
  "index": 1,
170
176
  "timestamp": {
171
- "iso": "2026-04-09T18:00:00Z",
177
+ "iso": "2026-04-09T18:00:00.001000Z",
172
178
  "unix": 1775757600001
173
179
  }
174
180
  }
@@ -190,7 +196,7 @@ Example output:
190
196
  "format": "standard",
191
197
  "output_as": "string",
192
198
  "count": 3,
193
- "items": "uuid-1,uuid-2,uuid-3"
199
+ "items": "uuid-1\nuuid-2\nuuid-3"
194
200
  }
195
201
  ```
196
202
 
@@ -211,18 +217,18 @@ Each object includes:
211
217
  - `uuid` = final formatted value
212
218
  - `raw` = original UUID before formatting
213
219
  - `index` = zero-based position in the result set
214
- - `timestamp` = only for v7, derived from the UUID
220
+ - `timestamp` = only included for `v7` when `outputAs="object"`
215
221
 
216
222
  ### `outputAs="string"`
217
223
 
218
- Returns `items` as a single comma-delimited string.
224
+ Returns `items` as a single newline-delimited string.
219
225
 
220
226
  ---
221
227
 
222
228
  ## Supported Versions
223
229
 
224
230
  - `v4` = random
225
- - `v7` = modern time-based
231
+ - `v7` = time-based, sortable, recommended
226
232
 
227
233
  ---
228
234
 
@@ -235,6 +241,29 @@ from uuid_kit import ALLOWED_FORMATS, ALLOWED_VERSIONS, ALLOWED_OUTPUT_AS
235
241
 
236
242
  ---
237
243
 
244
+ ## Behavior
245
+
246
+ - Invalid or missing `count` defaults to `1`
247
+ - `count` is capped at `100`
248
+ - `count` is converted to an integer
249
+ - Invalid or missing `version` defaults to `v7`
250
+ - Invalid or missing `format` defaults to `standard`
251
+ - Invalid or missing `outputAs` defaults to `array`
252
+
253
+ ---
254
+
255
+ ## Performance Notes
256
+
257
+ `uuid-kit` avoids unnecessary work during generation:
258
+
259
+ - Object records are only built when `outputAs="object"`
260
+ - Timestamps are only extracted for `v7` object output
261
+ - List storage is preallocated for efficient generation
262
+
263
+ This keeps array and string output paths lighter and faster.
264
+
265
+ ---
266
+
238
267
  ## Environment Notes
239
268
 
240
269
  Some hosted Python runtimes require you to explicitly add packages before use. In those environments, add:
@@ -246,16 +275,6 @@ uuid6
246
275
 
247
276
  ---
248
277
 
249
- ## Behavior
250
-
251
- - Invalid or missing `count` defaults to `1`
252
- - `count` is capped at `100`
253
- - Invalid or missing `version` defaults to `v7`
254
- - Invalid or missing `format` defaults to `standard`
255
- - Invalid or missing `outputAs` defaults to `array`
256
-
257
- ---
258
-
259
278
  ## Notes
260
279
 
261
280
  - Python standard library does not yet include native UUID v7 support
@@ -3,6 +3,7 @@ README.md
3
3
  pyproject.toml
4
4
  uuid_kit/__init__.py
5
5
  uuid_kit/core.py
6
+ uuid_kit/py.typed
6
7
  uuid_kit.egg-info/PKG-INFO
7
8
  uuid_kit.egg-info/SOURCES.txt
8
9
  uuid_kit.egg-info/dependency_links.txt
File without changes
File without changes
File without changes