0

I'm working on a python program that uses mpmath to implement the Chunovsky algorithm for computing pi. I want to make my program log its progress to a file on regular intervals, so that I can recover progress if there's a power outage or something similar, since the program will be running for a while. I'm using a dps of about a million, so converting to a decimal string is very slow. I need a way to encode an mpf object as a raw binary bytes or bytearray object. I can't seem to find anything about this in the mpmath documentation. I could serialize it with pickle, but I think it would be slower than necessary, since it would serialize more information than I need.

2
  • Why do you think pickle would be too much? Have you tried it? What do you know about the internal memory use of a mpf? I've used mpmath some, but haven't studied its docs. Commented Mar 21 at 14:45
  • After posting this, I tried pickling and it is quite fast, faster enough for my purposes. I'm pretty new to mpmath and I've only searched the docs for a conversion/serialization to bytes function, not studied it's internal memory usage. I'm still wondering about other ways to do it. Commented Mar 21 at 15:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.