I don't understand the obsession with Counter here. IMO it's a prime
example of sharing implementation through inheritance, an antipattern. It
implements the Mapping (i.e. read-only) interface fine, but while it has
all the methods of the MutableMapping interface, the behavior is
sufficiently different that you shouldn't pass it to code that was written
with a MutableMapping or dict in mind. It would have made more sense to
design an API specifically for Counter, and have the implementation use a
dict internally to hold the values (the "composition over inheritance"
pattern).

-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/ADKAACQJ2Q7RUWVZL47QZYIFZY5P73WV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to