[New-bugs-announce] [issue27358] BUILD_MAP_UNPACK_WITH_CALL is slow

Demur Rumed report at bugs.python.org
Mon Jun 20 21:46:01 EDT 2016


New submission from Demur Rumed:

BUILD_MAP_UNPACK_WITH_CALL is _really_ slow, wasting much of its time asserting that keys are non overlapping. This patch optimizes a fast path for distinct dicts, especially useful for #27213 where BUILD_MAP_UNPACK_WITH_CALL is generated for a single **kw rather than needing **kw1,**kw2 to hit this slow opcode

This patch tracks size of dictionary, if size doesn't increase by same size as the dict we updated sum with, then we scan to find where collision is. Further optimization can be done by scanning size of dicts to preallocate dictionary

Microbenchmark:
from timeit import timeit
def f(**x):return x
timeit(lambda:f(**{'a':2},**{'b':2}))

Unpatched takes ~15s
Patched takes ~5s

----------
files: mapaca.patch
keywords: patch
messages: 268951
nosy: Demur Rumed
priority: normal
severity: normal
status: open
title: BUILD_MAP_UNPACK_WITH_CALL is slow
Added file: http://bugs.python.org/file43494/mapaca.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27358>
_______________________________________


More information about the New-bugs-announce mailing list