fuzzylogician / gmpy

Automatically exported from code.google.com/p/gmpy
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Pickling? #89

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I have a suggestion, if it is appropriate here, I apologize.

Is it possible to write a hash, or pickle mpfr objects? It would be nice to 
have such a functionality when tedious calculations are required.

Original issue reported on code.google.com by philippl...@gmail.com on 20 Jul 2014 at 2:27

GoogleCodeExporter commented 8 years ago
Oops, it turns out there is a binary converter that works for mpfr... sorry, 
and thanks for your work on this module.

Original comment by philippl...@gmail.com on 20 Jul 2014 at 2:34

GoogleCodeExporter commented 8 years ago
You can either use to_binary()/from_binary() directly or use the pickle module. 
The pickle module just calls to_binary()/from_binary() in the background. Here 
is a simple example:

>>> import gmpy2, pickle
>>> flt = gmpy2.mpfr(1234.6789)
>>> flt == pickle.loads(pickle.dumps(flt))
True

Original comment by casevh on 21 Jul 2014 at 2:16