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). 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. -- https://mail.python.org/mailman/listinfo/python-list