Sep-24-2019, 02:17 PM
Reviving this old thread, after about 10 days of waiting I still had no answer so I broke the problem apart to see where the slowdown is. It's in the conversion from integer to string. I get the integer answer in less than 1 second. But, it's a huge integer. Conversion to a string so I can display it or write it to a file takes forever.
import datetime as dt start = dt.datetime.now() target = 2**34 alpha = 1<<target stop = dt.datetime.now() print(start, stop) input("Calculated value: ") start = dt.datetime.now() outstr = str(alpha) stop = dt.datetime.now() print(start, stop) input("Converted to string: ") start = dt.datetime.now() with open('c:\\Users\\summersj\\bignum.txt', 'w') as file : file.write(outstr) stop = dt.datetime.now() print(f"Wrote to file {start} {stop}")
Output:2019-09-24 10:15:24.725485 2019-09-24 10:15:25.651044
Calculated value: