frozendict: an experiment

Marco Sulla Marco.Sulla.Python at gmail.com
Sat Jul 18 17:38:14 EDT 2020


On Sat, 18 Jul 2020 at 10:02, Inada Naoki <songofacandy at gmail.com> wrote:

> On Sat, Jul 18, 2020 at 7:05 AM Marco Sulla
> <Marco.Sulla.Python at gmail.com> wrote:
> > For what I know, CPython uses PyDictObject for kwargs. Since dicts are
> > mutable, it's a problem to cache them properly.
>
> On caller side, Python doesn't use dict at all.
> On callee side, dict is used for `**kwargs`.  But changing it to
> frozendict is
> backward incompatible change.
>

Not sure of what you mean with caller and callee. If you're talking about
Python, I agree, kwargs must be dicts. But I was talking about CPython and
PyDictObject, that is used internally for kwargs.

On Sat, 18 Jul 2020 at 10:02, Inada Naoki <songofacandy at gmail.com> wrote:

> Currently, `for k,v in d.items()`
> doesn't create
> temporary list or set-like.
> I think using "real object" is not good performance optimization.
>

Well, this is true... but they create view objects that are quite slow.


More information about the Python-list mailing list