I'm trying klepto as a replacement for shelve to persist class instances but am seeing a lengthy traceback when attempting to do so.
My platform is: python 3.7.3 klepto 0.1.6
The example @ Pickle versus shelve storing large dictionaries in Python ... works fine on the above platform.
from dataclasses import dataclass
@dataclass (frozen=True)
class Target:
name : str
@dataclass (frozen=True)
class Image:
target :Target
image_1 = Image (target=Target(name='Crab Nebula'))
image_2 = Image (target=Target(name='Orion Nebula'))
##keys = image_1.name, image_2.name
keys = image_1.target.name, image_2.target.name
values = image_1, image_2
d = dict ( zip (keys,values))
import klepto
a = klepto.archives.dir_archive (dict=d)
a.dump()
a.dump() initiates a lengthy traceback beginning with ...
File "C:\Users\jgv\Documents\Projects\AstroPix_ODB (klepto)\stackoverflow.py", line 20, in <module>
a.dump()
File "C:\Users\jgv\AppData\Local\Programs\Python\Python37\lib\site-packages\klepto\_archives.py", line 165, in dump
self.archive.update(self)
and concluding with ...
File "C:\Users\jgv\AppData\Local\Programs\Python\Python37\lib\site-packages\dill\_dill.py", line 1148, in save_dictproxy
raise ReferenceError("%s does not reference a class __dict__" % obj)
ReferenceError: {} does not reference a class __dict__