I've done a PR: https://github.com/python/cpython/pull/22346
As you can see, changes are not dramatical, if you improve only kw creation. Furthermore, IMHO insert_to_emptydict() can be removed, since it speeds up the insertion of the first element, but slows down all the others. I do something similar in insertdict_init, but in "bulk mode". On Thu, 17 Sep 2020 at 16:49, Marco Sulla <[email protected]> wrote: > > On Thu, 17 Sep 2020 at 05:31, Inada Naoki <[email protected]> wrote: > > > > On Thu, Sep 17, 2020 at 8:03 AM Marco Sulla > > <[email protected]> wrote: > > > > > > python -m timeit -n 2000 --setup "from uuid import uuid4 ; o = > > > {str(uuid4()).replace('-', '') : str(uuid4()).replace('-', '') for i > > > in range(10000)}" "dict(**o)" > > > > > > > I don't think this use case is worth to optimize, because `dict(o)` or > > `o.copy()` is Pythonic. > > Well, also {**dict1, **dict2} is pythonic. Anyway, I used **dict as a > shortcut for testing keyword assignment. > For doing this I "only" cloned PyDict_SetItem and insertdict. > > I do not like code duplication, but dictobject.c has already a lot of > duplicated copies of the same function for optimization (see > lookdict). _______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/SPLALWGOKFSKXJL6ZA5LPY3TZXD6JQQH/ Code of Conduct: http://python.org/psf/codeofconduct/
