[Python-ideas] Revisiting Immutable Mappings
Chris Angelico
rosuav at gmail.com
Thu Oct 11 18:38:22 EDT 2018
On Fri, Oct 12, 2018 at 9:16 AM Steven D'Aprano <steve at pearwood.info> wrote:
>
> On Fri, Oct 12, 2018 at 02:45:30AM +1100, Chris Angelico wrote:
> > On Fri, Oct 12, 2018 at 2:41 AM Chris Barker - NOAA Federal via
> > Python-ideas <python-ideas at python.org> wrote:
> > >
> > > > This violates the Liskov Substitution Principle.
> > >
> > > If we REALLY had a time machine, then dict would subclass frozendict,
> > > and we’d be all set.
> >
> > Thanks to virtual subclassing, we can still do this. The question is, should we?
> >
> > Intuition tells me that a frozen dictionary is a form of dictionary
> > that adds restrictions, not that a dictionary is a frozen dictionary
> > that you left out to thaw.
>
> No offence Chris, but that's why we shouldn't program by intuition :-)
>
> > But as we see from [frozen]set, it's
> > probably best to treat them as completely independent classes, both
> > implementing the basic Mapping interface.
>
> Indeed.
>
Which was my point. They probably should NOT be in a direct hierarchy,
partly because people's intuition WILL lead them to a dangerous
expectation.
ChrisA
More information about the Python-ideas
mailing list