error when pickle dict with float (point sign) and tuple
I need to save dict structure to persistent storage using pickle. I have tuples and floats in it. But when I try to unpickle it I got error. To reproduce:
>>> d = {'a': 1.0, 'b': (1, 0)}
>>> pickle.loads(pickle.dumps(d))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pickle.py", line 20, in loads
ImportError: no module named '{'a': 1'
>>>
I solve this replacing tuples with lists. Also I notice that ujson converts tuple to list silently.
Thanks for report.
Pickle implementation is very, very basic and was tested with only very simple data structures. Apparently, wasn't tested with floats, as your case suggests. The idea is the same as with the rest of pycopy-lib: someone who would need more functionality might look into implementing it.
To solve it "completely", more planning/thinking/work is needed, e.g. https://github.com/pfalcon/pycopy/issues/8
Also I notice that ujson converts tuple to list silently.
This is likely how original CPython json module works either.