OrderedDict(kwargs) optimization?

On Wednesday, November 8, 2017, Guido van Rossum guido@python.org wrote:
It seems there must be at least two threads for each topic worth discussing at all. Therefore I feel compelled to point to https://mail.python.org/pipermail/python-dev/2017-November/150381.html, where I state my own conclusion about dict order.
.
Finally: the dict type should not be endowed with other parts of the OrderedDict API, not should other API changes to dict be considered.
Is there an opportunity to support a fast cast to OrderedDict from 3.6 dict? Can it just copy .keys() into the OrderedDict linked list?Or is there more overhead to the transition?
That'd be great for preserving kwargs' order after a pop() or a del?
def func(**kwargs): kwargs = OrderedDict(kwargs) arg2 = kwargs.pop('arg2')

That'd be great for preserving kwargs' order after a pop() or a del?
To clarify, order is preserved after pop in Python 3.6 (and maybe 3.7).
There is discussion about breaking it to optimize for limited use cases, but I don't think it's worth enough to discuss more until it demonstrates real performance gain.
Is there an opportunity to support a fast cast to OrderedDict from 3.6 dict? Can it just copy .keys() into the OrderedDict linked list?Or is there more overhead to the transition?
https://bugs.python.org/issue31265
Regards,
INADA Naoki songofacandy@gmail.com

Got it. Thanks!
On Wednesday, November 8, 2017, INADA Naoki songofacandy@gmail.com wrote:
That'd be great for preserving kwargs' order after a pop() or a del?
To clarify, order is preserved after pop in Python 3.6 (and maybe 3.7).
There is discussion about breaking it to optimize for limited use cases, but I don't think it's worth enough to discuss more until it demonstrates real performance gain.
Is there an opportunity to support a fast cast to OrderedDict from 3.6
dict?
Can it just copy .keys() into the OrderedDict linked list?Or is there
more overhead to the transition?
https://bugs.python.org/issue31265
Regards,
INADA Naoki <songofacandy@gmail.com javascript:;>
participants (2)
-
INADA Naoki
-
Wes Turner