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

[FEATURE REQUEST] make gemmi.cif.Block object picklable #258

Open
roshkjr opened this issue Mar 14, 2023 · 4 comments
Open

[FEATURE REQUEST] make gemmi.cif.Block object picklable #258

roshkjr opened this issue Mar 14, 2023 · 4 comments

Comments

@roshkjr
Copy link

roshkjr commented Mar 14, 2023

I am currently using gemmi.cif.Block object as an attribute of one of my python classes, and I would like to store this class using pickle. But currently I am not able to do so, because gemmi.cif.Block is not picklable.

It would be convenient if gemmi.cif.Block object can be pickled.

@wojdyr
Copy link
Member

wojdyr commented Mar 15, 2023

cif.Block is usually read from a file and/or written to a file, so I think it's rarely useful to additionally serialize it.
It could have getstate that returns JSON or CIF string, but maybe it's better to save it explicitly as JSON or CIF.

@jasondbiggs
Copy link

I don't see much point in pickling a Block or Document myself, since they can just be written to JSON or CIF. I would find it useful to pickle a Structure though, since there is a nonzero amount of overhead in serializing a Structure to mmCIF or mmJSON.

@joelb123
Copy link

Other areas of computational science have found that pickles are about the most energy-efficient serialization there is, generally about 3X higher than alternatives like Arrow (which is hundreds of times more efficient than CIF or JSON). If one accepts the caveat that the pickle will change when the library changes enough to affect the binary constructor, a Structure pickle can also be viewed as an extremely efficient and simple structure file format for gemmi.

@wojdyr
Copy link
Member

wojdyr commented Sep 12, 2023

We plan a serialization format for Structure in C++. Once we have it, I'll add __setstate__ and __getstate__.

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

No branches or pull requests

4 participants