[New-bugs-announce] [issue46085] OrderedDict iterator allocates di_result unnecessarily

Kevin Shweh report at bugs.python.org
Wed Dec 15 11:48:00 EST 2021


New submission from Kevin Shweh <kevin.shweh at gmail.com>:

The OrderedDict iterator caches a di_result tuple for use with iter(od.items()). It's *supposed* to only do that for the items() case, but the code does

    if (kind & (_odict_ITER_KEYS | _odict_ITER_VALUES))

to test for this case. This is the wrong test. It should be

    if ((kind & _odict_ITER_KEYS) && (kind &_odict_ITER_VALUES))

The current test allocates di_result for key and value iterators as well as items iterators.

----------
components: Library (Lib)
messages: 408616
nosy: Kevin Shweh
priority: normal
severity: normal
status: open
title: OrderedDict iterator allocates di_result unnecessarily
type: resource usage
versions: Python 3.10, Python 3.11, Python 3.8, Python 3.9

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


More information about the New-bugs-announce mailing list