On Wed, 29 Jul 2020 at 06:41, Inada Naoki <songofacandy@gmail.com> wrote:
FWIW, I optimized dict(d) in https://bugs.python.org/issue41431 (https://github.com/python/cpython/pull/21674 ) [...] 4.76x faster (-79%)
Great! On Wed, 29 Jul 2020 at 06:41, Inada Naoki <songofacandy@gmail.com> wrote:
On Sun, Jul 26, 2020 at 4:44 AM Marco Sulla <Marco.Sulla.Python@gmail.com> wrote:
I also remembered another possible use-case: kwargs in CPython. In C
code, kwargs are PyDictObjects. I suppose they are usually not modified; if so, fdict could be used, since it seems to be faster at creation.
[...] note that kwargs is not created by `dict(d)`. It is created by PyDict_New() and PyDict_SetItem().
Yes, I was really thinking about PyDict_New(). On Sat, 25 Jul 2020 at 21:55, Guido van Rossum <guido@python.org> wrote:
[...] Unfortunately it's impossible to change without breaking tons of existing code, since things like `kwds.pop("something")` have become a pretty standard idiom to use it.
Well, I was thinking about CPython code. Anyway, maybe there's a way to not break old code: def hello(name: str, **kwargs: frozendict) -> str: # code In the meanwhile I tried to optimize iteration. It seems also that iteration can be faster: https://github.com/Marco-Sulla/cpython/commit/3d802ba227eb588b0608f31cfa2357... I also done some other changes later, but for some reason I get a segfault now: https://github.com/Marco-Sulla/cpython/commit/51e2c45a5b7fa36f47aa55f2b4426c...