Message338927
3 years ago, Trey Hunter found 11 ways to merge to a new dict.
https://treyhunner.com/2016/02/how-to-merge-dictionaries-in-python/
He followed up with a performance comparison.
https://gist.github.com/treyhunner/f35292e676efa0be1728
** unpacking was nearly twice as fast as the 2nd place methods.
(Bigger dict might change the ratio, but I expect ** unpacking to remain first.)
Trey's summary: "This is simple and Pythonic. There are quite a few symbols, but it’s fairly clear that the output is a dictionary at least." I consider the last point a major plus.
User comment: "Beautiful. Pythonic. Thank you." No negatives. |
|
Date |
User |
Action |
Args |
2019-03-27 00:16:13 | terry.reedy | set | recipients:
+ terry.reedy, rhettinger, serhiy.storchaka |
2019-03-27 00:16:13 | terry.reedy | set | messageid: <1553645773.76.0.568810849183.issue36431@roundup.psfhosted.org> |
2019-03-27 00:16:13 | terry.reedy | link | issue36431 messages |
2019-03-27 00:16:13 | terry.reedy | create | |
|