-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pickle (as opposed to cPickle) support #271
Comments
The reason is simple: Python 2.7 I won't have time to chase down why Python 2.7 |
I wasn't aware of that 2.7 pickle behavior. After weighing my options I have actually taken this opportunity to convert my project to python 3. Thank you for the great work. |
I ran into this problem and since our project is unable to move on from Python 2.7, I solved this by implementing the reduce function as follows:
There is probably a better way of getting the python type object though. But this works for me. edit: Sadly it doesn't work mainly because of this line in pybind11.h:
I am not sure why setstate is treated as a constructor in Python 2.7, pickle is simply calling it after construction and ignores the result value. |
Hi everyone,
Could someone shed some light on the reason why pybind11 doesn't support pickle (as opposed to cPickle)?
Is there a hard reason or can it be worked on, in which case, could you provide some pointers?
I am migrating a project from boost::python to pybind11.
That project is using the flexibility that pickle (as opposed to cPickle) offers to substitute class/module/package names at unpickle time.
The idea is to unpickle transparently classes that have been renammed / moved and there is a decent number of pickled filed I'd rather not have to touch to be able to load them with pybind11.
`
def mapped_load_global(self):
module = mapname(self.readline()[:-1])
name = mapname(self.readline()[:-1])
klass = self.find_class(module, name)
self.append(klass)
unpickler = pickle.Unpickler(fileObj)
unpickler.dispatch[pickle.GLOBAL] = mapped_load_global
`
(can't get the code formating to work sorry)
The text was updated successfully, but these errors were encountered: