Replies: 1 comment
-
|
I think your request is reasonable. I prefer the way to remove a pickling instead of having multiple overloads. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi.
First of all thanks for the great project, has simplified getting my students to use our C++ code a lot!
I recently started on adding pickling support and ran into two problems (I opened two issues):
Issue:
I have a default pickling method that is automatically registered and would like to override that in certain cases.
Description:
Adding a second
def(pybind11::pickling...)does not work since the previous version is sued. Addingpybind11::prepend()leads to unexpected results - the default getstateis used together with the newsetstate. The reason is that in thepickle_factorytheextraargument is only added to thesetter. I can't find a workaround but was wondering if in this case having multiple overloads forsetstate/getstatemakes sense? Possibly a newdef(pickle(...))` should remove the first one or always prepend (that was easy enough to do)?Solution:
At least failing if
prependis used in the extra argument would probably avoid some unexpected behavior.What worked for me was testing for
pybind11:prependin theExtravariadic template when callingpickle_factory::executeand if present adding that to the__getstate__registration.I can provide a MR and possibly a test with that approach if it makes sense.
But as mentioned above perhaps simply removing a previous registration would be better since I believe that overloads would not be called anyway - I'm not that far down the rabbit hole yet to implement this approach.
Beta Was this translation helpful? Give feedback.
All reactions