Re: Immutable view classes - inherit from dict or from Mapping?

2021-04-13 Thread Serhiy Storchaka
13.04.21 15:47, Peter Otten пише: > As to the | operator, maybe it could be added to Mapping? The | operator returns a new instance, but constructor is not a part of the Mapping interface. You cannot make a general implementation, and making __or__ an abstract method will break all existing

Re: Immutable view classes - inherit from dict or from Mapping?

2021-04-13 Thread Serhiy Storchaka
12.04.21 19:01, Andreas R Maier пише: > Hi, > I have written some classes that represent immutable views on collections > (see "immutable-views" package on Pypi). > > Currently, these view classes inherit from the abstract collection classes > such as Mapping, Sequence, Set. However, they

Re: Immutable view classes - inherit from dict or from Mapping?

2021-04-13 Thread Peter Otten
On 12/04/2021 18:01, Andreas R Maier wrote: Hi, I have written some classes that represent immutable views on collections (see "immutable-views" package on Pypi). Currently, these view classes inherit from the abstract collection classes such as Mapping, Sequence, Set. However, they implement

Immutable view classes - inherit from dict or from Mapping?

2021-04-12 Thread Andreas R Maier
Hi, I have written some classes that represent immutable views on collections (see "immutable-views" package on Pypi). Currently, these view classes inherit from the abstract collection classes such as Mapping, Sequence, Set. However, they implement the read-only methods of dict, list and set,