Should I use marshal if I am getting comma errors in JSON (Python)? -


i using python dump huge data structure (multiple lists , dictionaries) , sending on socket client.

i keep getting valueerror: 'expecting ',' delimiter: line 1 column 16177 (char 16176) @ various different locations every time run program (it column 25000, or column 13000, keeps changing).

should use marshal instead of json (or pickle)? reliable format large file sizes?

i'd suggest use pickle (or cpickle if you're on python 2.x) can serialize anything, including user-defined classes. and, docs say

the marshal serialization format not guaranteed portable across python versions. because primary job in life support .pyc files, python implementers reserve right change serialization format in non-backwards compatible ways should need arise. pickle serialization format guaranteed backwards compatible across python releases.

(emphasis mine).

another advantage of pickle:

the pickle module keeps track of objects has serialized, later references same object won’t serialized again. marshal doesn’t this.

this has implications both recursive objects , object sharing. recursive objects objects contain references themselves. these not handled marshal, , in fact, attempting marshal recursive objects crash python interpreter. object sharing happens when there multiple references same object in different places in object hierarchy being serialized. pickle stores such objects once, , ensures other references point master copy. shared objects remain shared, can important mutable objects.

you can use dill if pickle fails serialize data.


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -