Open phasefactor opened 4 months ago
It seems intentional. Maybe @ihincks has more context.
I also came here to suggest this. IIRC the decision has something to with restricting the slots in resulting objects.
I would personally benefit a lot from this because it consequently prevents PrimitiveResult
objects from being pickled as well.
import pickle
from qiskit.primitives.containers import DataBin
filename = "tmp.pkl"
with open(filename, "wb") as f:
pickle.dump(DataBin(x=[1]), f)
with open(filename, "rb") as f:
pickle.load(f)
What should we add?
Currently when using pickle with
PrimitiveResult
orPubResult
theDataBin
class will throw aNotImplementedError
from__setattr__()
when you try topickle.load()
.The change needed is trivial, so I was not sure if this omission was originally made on purpose...
However, I think being able to save results locally instead of relying on referencing them by job id would be a benefit.
There is some value in not requiring network connectivity and making them easily shareable/archive-able.
The necessary change to databin.py: 96 is :