[issue32792] ChainMap should preserve order of underlying mappings

2018-02-11 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue32792] ChainMap should preserve order of underlying mappings

2018-02-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I referred to msg311969, not msg311822. -- ___ Python tracker ___ ___ Python-bugs-list mailing l

[issue32792] ChainMap should preserve order of underlying mappings

2018-02-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: > The code in msg311969 doesn't reuse hash values. That doesn't make sense. The dict.update() method reuses the hashes of the input mappings when possible. >>> from collections import ChainMap >>> class Int(int): def __hash__(self):

[issue32792] ChainMap should preserve order of underlying mappings

2018-02-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 170b3f79506480f78275a801822c9ff1283e16f2 by Raymond Hettinger (Miss Islington (bot)) in branch '3.7': bpo-32792: Preserve mapping order in ChainMap() (GH-5586) (#GH-5617) https://github.com/python/cpython/commit/170b3f79506480f78275a801822c9ff

[issue32792] ChainMap should preserve order of underlying mappings

2018-02-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The code in msg311969 doesn't reuse hash values. The following implementations do this: return iter({**m for m in reversed(self.maps)}) or, without keeping reverences to values: return iter(list({**m for m in reversed(self.maps)})) -- ___

[issue32792] ChainMap should preserve order of underlying mappings

2018-02-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: On PR 5586 we discussed reverting the order of the iteration by mappings. There are reasons of doing this. But this adds a subtle behavior change. Currently list(ChainMap({1: int}, {1.0: float})) returns [1]. With reversed() it will return [1.0]. This chang

[issue32792] ChainMap should preserve order of underlying mappings

2018-02-11 Thread miss-islington
Change by miss-islington : -- pull_requests: +5427 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mai

[issue32792] ChainMap should preserve order of underlying mappings

2018-02-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 3793f95f98c3112ce447288a5bf9899eb9e35423 by Raymond Hettinger in branch 'master': bpo-32792: Preserve mapping order in ChainMap() (GH-5586) https://github.com/python/cpython/commit/3793f95f98c3112ce447288a5bf9899eb9e35423 -- ___

[issue32792] ChainMap should preserve order of underlying mappings

2018-02-10 Thread Serhiy Storchaka
Serhiy Storchaka 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. I

[issue32792] ChainMap should preserve order of underlying mappings

2018-02-08 Thread Ned Deily
Ned Deily added the comment: See discussion on PR 5586 regarding backporting to 3.6.x. -- versions: -Python 3.6 ___ Python tracker ___

[issue32792] ChainMap should preserve order of underlying mappings

2018-02-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: An alternate implementation: d = {} for mapping in reversed(self.maps): d.update(mapping) return iter(d) Unfortunately both implementations work only with hashable keys. In general case mappings may be not hashtables. -- __

[issue32792] ChainMap should preserve order of underlying mappings

2018-02-08 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- nosy: +ned.deily, serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscri

[issue32792] ChainMap should preserve order of underlying mappings

2018-02-08 Thread Raymond Hettinger
Change by Raymond Hettinger : -- keywords: +patch pull_requests: +5404 stage: -> patch review ___ Python tracker ___ ___ Python-bugs

[issue32792] ChainMap should preserve order of underlying mappings

2018-02-08 Thread Raymond Hettinger
New submission from Raymond Hettinger : This also applies to 3.6 because ChainMap can be used with OrderedDict. -- components: Library (Lib) messages: 311817 nosy: rhettinger priority: normal severity: normal status: open title: ChainMap should preserve order of underlying mappings type: