Storing instances using jsonpickle

Josh English Joshua.R.English at gmail.com
Thu Sep 4 00:30:00 CEST 2014


On Wednesday, September 3, 2014 1:53:23 PM UTC-7, Ned Batchelder wrote:

> Pickle (and it looks like jsonpickle) does not invoke the class' 
> __init__ method when it reconstitutes objects.  Your new __init__ is not 
> being run, so new attributes it defines are not being created.
>
> This is one of the reasons that people avoid pickle: being completely 
> implicit is very handy, but also fragile.
> 

I seem to remember having this exact same frustration when I used pickle and shelve 15 years ago. I had hoped to have another way around this. I spent over a decade trying to make an XML-based database work, in part because of this limitation.

Some days I get so frustrated I think the only data structure I should ever use is a dictionary.

I suppose to make this sort of thing work, I should look at creating custom json encoders and decoders.

Thanks,

Josh




More information about the Python-list mailing list