[issue32792] ChainMap should preserve order of underlying mappings

Serhiy Storchaka report at bugs.python.org
Sat Feb 10 18:03:37 EST 2018


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

Sorry, I was wrong. reversed() is not needed here.

The advantage of this implementation is that it can be faster because of iterating mappings in C code instead of Python code. But the side effect of it is that the iterator keeps references to all values. If this is not desirable, the code can be written something like:

    return iter(dict.fromkeys(itertools.chain.from_iterable(self.maps)))

----------

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


More information about the Python-bugs-list mailing list