[issue18352] collections.Counter with added attributes are not deepcopied properly.

2014-02-17 Thread Jesús Cea Avión
Changes by Jesús Cea Avión : -- nosy: +jcea ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python

[issue18352] collections.Counter with added attributes are not deepcopied properly.

2013-07-13 Thread Olivier Gagnon
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. Those individu

[issue18352] collections.Counter with added attributes are not deepcopied properly.

2013-07-12 Thread Raymond Hettinger
Raymond Hettinger added the comment: Do you guys have any actual motivating use cases or real code that won't work because of the present design? Consistency arguments are somewhat weak and don't necessarily warrant an API change. AFAICT, there is no use for counters going out of their wa

[issue18352] collections.Counter with added attributes are not deepcopied properly.

2013-07-12 Thread Olivier Gagnon
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 _

[issue18352] collections.Counter with added attributes are not deepcopied properly.

2013-07-12 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: What about pickling? OrderedDict.__reduce__() saves added attributes, but Counter.__reduce__() does not. One of them should be changed for consistency. -- ___ Python tracker ___

[issue18352] collections.Counter with added attributes are not deepcopied properly.

2013-07-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: I don't want the current behavior to change. The copy() method does not guarantee that it will copy added attributes. -- resolution: -> rejected status: open -> closed ___ Python tracker

[issue18352] collections.Counter with added attributes are not deepcopied properly.

2013-07-11 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: -> rhettinger priority: normal -> low ___ Python tracker ___ ___ Python-bugs-list mailing

[issue18352] collections.Counter with added attributes are not deepcopied properly.

2013-07-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Here is an updated patch. It includes a fix for OrderedDict.copy(). Counter's copy() and __reduce__() are simplified. Added tests for OrderedDict which checks that OrderedDict copying and pickling preserves dynamic attributes. -- Added file: http://b

[issue18352] collections.Counter with added attributes are not deepcopied properly.

2013-07-10 Thread Olivier Gagnon
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 ... >>> l

[issue18352] collections.Counter with added attributes are not deepcopied properly.

2013-07-10 Thread Vajrasky Kok
Vajrasky Kok added the comment: The question is whether we should give the freedom to user to add dynamic attribute to Counter object. Is this freedom has any practicality? Why do we want to add dynamic attributes to Counter object? Decimal object does not have this freedom. >>> from decimal

[issue18352] collections.Counter with added attributes are not deepcopied properly.

2013-07-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I mean OrderedDict.copy(). -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe

[issue18352] collections.Counter with added attributes are not deepcopied properly.

2013-07-03 Thread Eric Snow
Eric Snow added the comment: OrderedDict already copies the instance dict in __reduce__(). Are you talking about something more than that? -- nosy: +eric.snow ___ Python tracker __

[issue18352] collections.Counter with added attributes are not deepcopied properly.

2013-07-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Here is a preliminary patch. It changes copying and pickling to preserve instance attributes. Actually I'm not sure which attributes should be copied. I doubt -- should this be considered as a fix or as a new feature? Perhaps OrderedDict should be changed in

[issue18352] collections.Counter with added attributes are not deepcopied properly.

2013-07-03 Thread Madison May
Changes by Madison May : -- nosy: +madison.may ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyth

[issue18352] collections.Counter with added attributes are not deepcopied properly.

2013-07-03 Thread Olivier Gagnon
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) # prints 3 cou