Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(44608)

Side by Side Diff: Lib/uuid.py

Issue 18784: minor uuid.py loading optimization
Patch Set: Created 6 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 r"""UUID objects (universally unique identifiers) according to RFC 4122. 1 r"""UUID objects (universally unique identifiers) according to RFC 4122.
2 2
3 This module provides immutable UUID objects (class UUID) and the functions 3 This module provides immutable UUID objects (class UUID) and the functions
4 uuid1(), uuid3(), uuid4(), uuid5() for generating version 1, 3, 4, and 5 4 uuid1(), uuid3(), uuid4(), uuid5() for generating version 1, 3, 4, and 5
5 UUIDs as specified in RFC 4122. 5 UUIDs as specified in RFC 4122.
6 6
7 If all you want is a unique ID, you should probably call uuid1() or uuid4(). 7 If all you want is a unique ID, you should probably call uuid1() or uuid4().
8 Note that uuid1() may compromise privacy since it creates a UUID containing 8 Note that uuid1() may compromise privacy since it creates a UUID containing
9 the computer's network address. uuid4() creates a random UUID. 9 the computer's network address. uuid4() creates a random UUID.
10 10
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 # Linux and FreeBSD, and provided by libc on Mac OS X. 422 # Linux and FreeBSD, and provided by libc on Mac OS X.
423 for libname in ['uuid', 'c']: 423 for libname in ['uuid', 'c']:
424 try: 424 try:
425 lib = ctypes.CDLL(ctypes.util.find_library(libname)) 425 lib = ctypes.CDLL(ctypes.util.find_library(libname))
426 except: 426 except:
427 continue 427 continue
428 if hasattr(lib, 'uuid_generate_random'): 428 if hasattr(lib, 'uuid_generate_random'):
429 _uuid_generate_random = lib.uuid_generate_random 429 _uuid_generate_random = lib.uuid_generate_random
430 if hasattr(lib, 'uuid_generate_time'): 430 if hasattr(lib, 'uuid_generate_time'):
431 _uuid_generate_time = lib.uuid_generate_time 431 _uuid_generate_time = lib.uuid_generate_time
432 if _uuid_generate_random is not None:
433 break # found everything we were looking for
432 434
433 # The uuid_generate_* functions are broken on MacOS X 10.5, as noted 435 # The uuid_generate_* functions are broken on MacOS X 10.5, as noted
434 # in issue #8621 the function generates the same sequence of values 436 # in issue #8621 the function generates the same sequence of values
435 # in the parent process and all children created using fork (unless 437 # in the parent process and all children created using fork (unless
436 # those children use exec as well). 438 # those children use exec as well).
437 # 439 #
438 # Assume that the uuid_generate functions are broken from 10.5 onward, 440 # Assume that the uuid_generate functions are broken from 10.5 onward,
439 # the test can be adjusted when a later version is fixed. 441 # the test can be adjusted when a later version is fixed.
440 import sys 442 import sys
441 if sys.platform == 'darwin': 443 if sys.platform == 'darwin':
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 from hashlib import sha1 574 from hashlib import sha1
573 hash = sha1(namespace.bytes + bytes(name, "utf-8")).digest() 575 hash = sha1(namespace.bytes + bytes(name, "utf-8")).digest()
574 return UUID(bytes=hash[:16], version=5) 576 return UUID(bytes=hash[:16], version=5)
575 577
576 # The following standard UUIDs are for use with uuid3() or uuid5(). 578 # The following standard UUIDs are for use with uuid3() or uuid5().
577 579
578 NAMESPACE_DNS = UUID('6ba7b810-9dad-11d1-80b4-00c04fd430c8') 580 NAMESPACE_DNS = UUID('6ba7b810-9dad-11d1-80b4-00c04fd430c8')
579 NAMESPACE_URL = UUID('6ba7b811-9dad-11d1-80b4-00c04fd430c8') 581 NAMESPACE_URL = UUID('6ba7b811-9dad-11d1-80b4-00c04fd430c8')
580 NAMESPACE_OID = UUID('6ba7b812-9dad-11d1-80b4-00c04fd430c8') 582 NAMESPACE_OID = UUID('6ba7b812-9dad-11d1-80b4-00c04fd430c8')
581 NAMESPACE_X500 = UUID('6ba7b814-9dad-11d1-80b4-00c04fd430c8') 583 NAMESPACE_X500 = UUID('6ba7b814-9dad-11d1-80b4-00c04fd430c8')
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+