[New-bugs-announce] [issue42141] Speedup various dict inits

Marco Sulla report at bugs.python.org
Sat Oct 24 17:17:49 EDT 2020


New submission from Marco Sulla <launchpad.net at marco.sulla.e4ward.com>:

The PR #22948 is an augmented version of #22346. It speeds up also the creation of:

1. dicts from other dicts that are not "perfect" (combined and without holes)
2. fromkeys
3. copies of dicts with many holes
4. dict from keywords, as in #22346

A sample bench:

python -m pyperf timeit --rigorous "dict(o)" -s """
from uuid import uuid4

def getUuid():
    return str(uuid4())

o = {getUuid():getUuid() for i in range(1000)}
delkey = getUuid()
o[delkey] = getUuid()
del o[delkey]
"""
.........................................

Before #22948:
Mean +- std dev: 35.9 us +- 0.6 us

After:
Mean +- std dev: 26.4 us +- 0.4 us

----------
messages: 379540
nosy: Marco Sulla
priority: normal
pull_requests: 21865
severity: normal
status: open
title: Speedup various dict inits

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42141>
_______________________________________


More information about the New-bugs-announce mailing list