[Python-ideas] OrderedCounter and OrderedDefaultDict

Sven R. Kunze srkunze at mail.de
Wed Oct 21 19:41:55 CEST 2015


On 21.10.2015 00:50, Chris Angelico wrote:
> She recommends a massive superclass that's capable of any form of injection

Nope. She does not.

The "superclass" is not "massive" at all. It is even slimmer as 
orthogonal aspects are refactored out into separate entities. In fact, 
it makes it even easier to test and maintain these separate aspects (the 
core dev should be interested in that). Furthermore, it's, of course, up 
to debate which aspects should be injectable and which are not.


Just imagine, I would need to use several orderings and/or a default 
value for missing keys:

normal_dict = dict()
ordered_dict = dict(order=dict.order_by_insert)
sorted_dict = dict(order=sorted)
sorted_default_dict = dict(order=sorted, default=int)


How many subclasses am I supposed to write, maintain and upgrade (in 
case Guido rewrites his precious dict implementation)? I would even 
allege that for sufficiently large teams and projects, there are 
*multiple* implementations with the same intent.


Please, no.


Best,
Sven


PS: the instances above are real-world examples, I remember requiring 
during the course of the last year.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20151021/2f1a8e02/attachment.html>


More information about the Python-ideas mailing list