[New-bugs-announce] [issue45556] uuid.uuid4() fast optimization
Mosquito
report at bugs.python.org
Thu Oct 21 11:03:58 EDT 2021
New submission from Mosquito <me at mosquito.su>:
I does a small experiment, and found out that if you generate UUID4 with int instead of sequence of bytes, then the generation of UUID4 occurs up to three times faster.
.. code-block: python
import random
import uuid
print("uuid.uuid4()")
%timeit uuid.uuid4()
# 5.49 µs ± 120 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
print("uuid.UUID(int=random.getrandbits(128), version=4)")
%timeit uuid.UUID(int=random.getrandbits(128), version=4)
# 2.58 µs ± 94.5 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
I have already made fixes to my fork on GH, tell me, will it be useful to someone else besides me?
----------
components: Library (Lib)
files: 0001-Generating-uuid.uuid4-up-to-three-times-faster.patch
keywords: patch
messages: 404607
nosy: mosquito
priority: normal
severity: normal
status: open
title: uuid.uuid4() fast optimization
type: performance
versions: Python 3.10
Added file: https://bugs.python.org/file50381/0001-Generating-uuid.uuid4-up-to-three-times-faster.patch
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45556>
_______________________________________
More information about the New-bugs-announce
mailing list