gap-packages / io

GAP package IO to do input and output
https://gap-packages.github.io/io/
Other
14 stars 14 forks source link

pickling to strings? #75

Open dimpase opened 5 years ago

dimpase commented 5 years ago

Sometimes it is better to have a pickle to a string, or to a memory area, e.g. in libgap setting, where GAP objects might be parts of a bigger structure that needs to be pickled, e.g. a Python one, cf https://docs.python.org/2/library/pickle.html

I imagine it should not be too hard to provide, as the existing in IO code surely has all the needed parts available, but is these a chance such a change is accepted and merged?

olexandr-konovalov commented 5 years ago

@dimpase I have IO_PickleToString and IO_UnpickleFromString (see https://gap-packages.github.io/scscp/doc/chap9.html#X84F055ED860120D5). Historically this appeared in SCSCP to satisfy its needs, and I am happy to submit a PR and move them to IO.

dimpase commented 5 years ago

This looks like a reasonable thing to do, thanks in advance!

fingolfin commented 3 years ago

PRs welcome :-)

ChrisJefferson commented 3 years ago

Stupid question, isn't what you want already there (this doesn't let you specify a memory block (edit: was group)). This has been there since 2011.

gap> s := IO_Pickle(Group((1,2,3)));
"PRMGILIS\>1PERM\>7(1,2,3)FAILFAIL"
gap> IO_Unpickle(s);
Group([ (1,2,3) ])
ChrisJefferson commented 3 years ago

Quickly checking, I notice this isn't documented, so that's a problem :)

dimpase commented 3 years ago

Document it, or it doesn't exist! :-)

And so we'd be busily picking GAP groups.

I don't understand what do you mean by saying that it doesn't let you specify a group.

ChrisJefferson commented 3 years ago

I meant existing memory block, which you mentioned, obviously had groups on the brain.

ChrisJefferson commented 3 years ago

Just in case you hit it, if you pickle permutation groups which are the results of GAP computations you might hit https://github.com/gap-packages/io/pull/91 ( which was just found by me, and fixed, a few days ago). This will only be a problem if you pickle the identity group, and only then the identity group returned by some GAP methods.