Skip to content

Commit 8ba3d8b

Browse files
committed
Improve hexadecimal masks reading
1 parent 7be6dc4 commit 8ba3d8b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Lib/uuid.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -722,10 +722,12 @@ def uuid5(namespace, name):
722722

723723
def uuid8(a=None, b=None, c=None):
724724
"""Generate a UUID from three custom blocks.
725-
'a' is the first 48-bit chunk of the UUID (octets 0-5);
726-
'b' is the mid 12-bit chunk (octets 6-7);
727-
'c' is the last 62-bit chunk (octets 8-15).
728-
When a value is not specified, a random value is generated.
725+
726+
* 'a' is the first 48-bit chunk of the UUID (octets 0-5);
727+
* 'b' is the mid 12-bit chunk (octets 6-7);
728+
* 'c' is the last 62-bit chunk (octets 8-15).
729+
730+
When a value is not specified, a pseudo-random value is generated.
729731
"""
730732
if a is None:
731733
import random
@@ -736,10 +738,9 @@ def uuid8(a=None, b=None, c=None):
736738
if c is None:
737739
import random
738740
c = random.getrandbits(62)
739-
740-
int_uuid_8 = (a & 0xffffffffffff) << 80
741+
int_uuid_8 = (a & 0xffff_ffff_ffff) << 80
741742
int_uuid_8 |= (b & 0xfff) << 64
742-
int_uuid_8 |= c & 0x3fffffffffffffff
743+
int_uuid_8 |= c & 0x3fff_ffff_ffff_ffff
743744
return UUID(int=int_uuid_8, version=8)
744745

745746
def main():

0 commit comments

Comments
 (0)