Skip to content
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

Not serializable by pickle or cloudpickle #114

Open
ccaapton opened this issue Sep 23, 2024 · 3 comments
Open

Not serializable by pickle or cloudpickle #114

ccaapton opened this issue Sep 23, 2024 · 3 comments

Comments

@ccaapton
Copy link

I need to apply jq in a pyspark distributed environment, thus the 'jq._Program' need to be serialized to be transported to the remote machine. But it encounters the below error:
TypeError: no default __reduce__ due to non-trivial __cinit__

code to reproduce:

import pickle
pickle.dumps(jq.compile('.a'))
@mwilliamson
Copy link
Owner

Could you pickle the program string instead, rather than the compiled program?

@ccaapton
Copy link
Author

ccaapton commented Sep 24, 2024

Could you pickle the program string instead, rather than the compiled program?

Sure I could compile the string inside a remote function, but I'm concerned about the computing cost of compiling the string each time the function is called, since it loops over a large dataframe. I profiled it and find it costs 5ms per call. Usually serialization/deserialization are much faster.

@mwilliamson
Copy link
Owner

I can't say I'm particularly familiar with pickling, but given a jq program contains native data, would an implementation of pickling the program not have to serialise the program string rather than the raw bytes anyway?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants