We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
divmod()
1 parent 3fc9af8 commit 8a19eb1Copy full SHA for 8a19eb1
1 file changed
src/uuid6/__init__.py
@@ -80,13 +80,12 @@ def uuid7() -> UUID:
80
if _last_v7_timestamp is not None and nanoseconds <= _last_v7_timestamp:
81
nanoseconds = _last_v7_timestamp + 1
82
_last_v7_timestamp = nanoseconds
83
- timestamp_s = nanoseconds // 10 ** 9
84
- timestamp_ns = nanoseconds - 10 ** 9 * timestamp_s
+ timestamp_s, timestamp_ns = divmod(nanoseconds, 10 ** 9)
85
subsec_a = timestamp_ns >> 18
86
subsec_b = (timestamp_ns >> 6) & 0x0FFF
87
subsec_seq_node = (timestamp_ns & 0x3F) << 56
88
subsec_seq_node += _getrandbits(56)
89
- uuid_int = (timestamp_s & 0xFFFFFFFF) << 92
+ uuid_int = (timestamp_s & 0x0FFFFFFFFF) << 92
90
uuid_int += subsec_a << 80
91
uuid_int += subsec_b << 64
92
uuid_int += subsec_seq_node
0 commit comments