On Wed, 29 Jul 2020 at 06:41, Inada Naoki <songofaca...@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 <songofaca...@gmail.com> wrote: > On Sun, Jul 26, 2020 at 4:44 AM Marco Sulla > <marco.sulla.pyt...@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 <gu...@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/3d802ba227eb588b0608f31cfa2357064b4726bf I also done some other changes later, but for some reason I get a segfault now: https://github.com/Marco-Sulla/cpython/commit/51e2c45a5b7fa36f47aa55f2b4426c0dc09baab6
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/AYJN2BVWU5F2SR3D7L5I7P6K2HHLZLTW/ Code of Conduct: http://python.org/psf/codeofconduct/