Olivier Gagnon added the comment:
Yes I do have code that break because of this behaviour. I'm doing evolutionary
algorithm using a framework called DEAP. This framework creates a type called
individual at the runtime by subclassing a container and adding it a fitness
attribute.
Olivier Gagnon added the comment:
I can understand that the current behaviour can be correct in regard with the
added attributes of the object. However, should I open a new issue for the
following inheritance behaviour which the reduce function affects also.
class myCounter(Counter):
def
Olivier Gagnon added the comment:
The dictionary and the set do not give the freedom to add dynamic attributes to
them. I agree that the Counter should have the same behaviour.
However, this will raise the same bug when we inherit from a Counter object.
>>> class mylist(list): pass
.
New submission from Olivier Gagnon:
The following code shows that the Counter is not deepcopied properly. The
same code with an user defined class or a dict is copied with the "b" attribute.
import collections
import copy
count = collections.Counter()
count.b = 3
print(count.b)