Skip to content

Commit 60877e4

Browse files
authored
Update Lib/uuid.py
1 parent 299d7a5 commit 60877e4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Lib/uuid.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -884,11 +884,11 @@ def uuid7():
884884
_last_counter_v7_overflow = False
885885
else:
886886
if timestamp_ms < _last_timestamp_v7:
887+
# The clock went backwards or we are within the same timestamp
888+
# after a counter overflow. We follow the RFC for in the former
889+
# case. In the latter case, we re-use the already advanced
890+
# timestamp (it was updated when we detected the overflow).
887891
if _last_counter_v7_overflow:
888-
# The clock went backward but RFC asks to update the timestamp
889-
# and advance the previous counter. We however do not want to
890-
# advance the timestamp again if we already advanced it once
891-
# due to an overflow (re-use the already advanced timestamp).
892892
timestamp_ms = _last_timestamp_v7
893893
else:
894894
timestamp_ms = _last_timestamp_v7 + 1

0 commit comments

Comments
 (0)