[issue31954] Don't prevent dict optimization by coupling with OrderedDict

Serhiy Storchaka report at bugs.python.org
Mon Nov 6 04:38:01 EST 2017


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

Currently OrderedDict uses a table of nodes that mirrors the dict table. For keeping it in sync it saves the size and address of the dict table. There are two issues with this. First, this prevent some kind of dict optimization. When dict is resized (after exhausting usable entries at the end of table) it should allocate a new table even if it's size isn't changed. Second, this doesn't guarantees that both tables are in sync. If the dict table was reallocated twice before using OrderedDict methods, it can have the same size and address, but totally different layout of elements.

Proposed PR adds a new flag to dict object. It is set when OrderedDict creates its table, and is cleared when dict reallocates its table or moves items in the same table.

----------
components: Interpreter Core
messages: 305623
nosy: inada.naoki, rhettinger, serhiy.storchaka, tim.peters
priority: normal
severity: normal
status: open
title: Don't prevent dict optimization by coupling with OrderedDict
type: enhancement
versions: Python 3.7

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


More information about the Python-bugs-list mailing list