This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author alexandre.vassalotti
Recipients alexandre.vassalotti, christian.heimes, georg.brandl
Date 2008-10-30.03:00:30
SpamBayes Score 4.6075034e-05
Marked as misclassified No
Message-id <1225335631.86.0.342668979164.issue3816@psf.upfronthosting.co.za>
In-reply-to
Content
> Without the __reduce__ method the information in __dict__ and 
> the class would be lost.

Are you sure about that?


Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) 
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
>>> class mydict(dict): pass
... 
>>> D = mydict({1:"one",2:"two"})
>>> D.foo = 3
>>> import pickle
>>> E = pickle.loads(pickle.dumps(D))
>>> E.foo
3
>>> E
{1: 'one', 2: 'two'}
>>> type(E)
<class '__main__.mydict'>
>>> F = pickle.loads(pickle.dumps(D, 2))
>>> F.foo
3
>>> F
{1: 'one', 2: 'two'}
>>> type(F)
<class '__main__.mydict'>
History
Date User Action Args
2008-10-30 03:00:32alexandre.vassalottisetrecipients: + alexandre.vassalotti, georg.brandl, christian.heimes
2008-10-30 03:00:31alexandre.vassalottisetmessageid: <1225335631.86.0.342668979164.issue3816@psf.upfronthosting.co.za>
2008-10-30 03:00:31alexandre.vassalottilinkissue3816 messages
2008-10-30 03:00:30alexandre.vassalotticreate