I want to write a really large integer from Python to a textfile, about 10 to 1000 Megabyte.
The following options have the same speed, unfortunately both are really slow:
import time
import pickle
num = 17**(10**7)
t1=time.time()
pickle.dump( num , open( "save2.p", "wb" ) )
t2=time.time()
print(str(t2-t1))
t3=time.time()
file = open("testfile2.txt","w")
file.write(str(num))
file.close()
t4=time.time()
print(str(t4-t3))
(of course, the value of num
is just a placeholder for another big integer)
My questions:
- Is there a faster way to write a human-readable file with the decimal digits?
- If not, how can I write it faster without human-readability?
Who can help?