On Thu, Jul 16, 2020 at 2:32 AM Marco Sulla <marco.sulla.pyt...@gmail.com> wrote: > > On Wed, 15 Jul 2020 at 08:07, Inada Naoki <songofaca...@gmail.com> wrote: > > I don't think so. The view objects are useful when we need a set-like > > operation. (e.g. `assert d.keys() == {"spam", "egg"}`) > > Yes, but, instead of creating a view, you can create and cache the > pointer of a "real" object, that implements the dict view API. > For example, keys for a frozendict could be an "ordered" frozenset. > This "oset" could be a frozendict, which values are the keys and the > keys are the key hashes (as set). >
I am not sure about what are you saying. Does it really solve the usage of dict views? How about my example? (`assert d.keys() == {"spam", "egg"}`) > On Wed, 15 Jul 2020 at 08:07, Inada Naoki <songofaca...@gmail.com> wrote: > > There is no difference between mutable and immutable dicts. > > There's a huge difference, and it's in the contract. As I said, if we > assume that a frozendict is immutable, we can optimize its speed. > Furthermore, currently no real functional programming can be done in > Python with dicts. Oh, ! am talking about dict views. I meant there is no difference between "how dict view is useful for dict" and "how dict view is useful for frozendict". But I am still not sure about the optimizations and functional programming you are talking about. Please elaborate more, please? -- Inada Naoki <songofaca...@gmail.com> -- https://mail.python.org/mailman/listinfo/python-list