# Feature or enhancement > CPython 3.11 is on average [25% faster](https://github.com/faster-cpython/ideas#published-results) than CPython 3.10 Therefore hope the python 3.12 stdlibs can get optimized as well, since maybe web could use secrets tokens a lot # Pitch https://github.com/python/cpython/blob/7c9c993945a63dc774554a8cc5ee1ef62a2454c7/Lib/secrets.py#L48-L59 ```py import os t = os.urandom(32) # Before: timeit binascii.hexlify(t).decode('ascii') # 215 ns ± 6.7 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each) # After: timeit t.hex() # 91 ns ± 1.6 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each) ``` > <!-- gh-pr-number: gh-99306 --> * PR: gh-99306 <!-- /gh-pr-number -->
Activity
gh-99305: Speed up secrets.token_hex() ~2x (#99306)
hauntsaninja commentedon Nov 29, 2022
Thanks for improving this!