On 2/14/11 7:06 AM, Matthew Gwynne wrote:
> Hi,
>
> I've just been running some tests as some computations we were doing
> were taking a long time to output their results to file. In Maxima, to
> generate a file with 100,000 lines of length 500, it takes around 8s
> for me, and yet it seems this should take less than a second?
>
> For example:
>
> (%i12) A : apply(sconcat,create_list("1",i,1,500))$
> Evaluation took 0.0000 seconds (0.0070 elapsed)
> (%i13) with_stdout("test.txt", for i : 1 thru 100000 do print(A))$
> Evaluation took 7.1600 seconds (7.4840 elapsed)
>
> while with the following python script (test.py):
>
> fh = open("test.txt", "w")
> testline = "1" * 500 + "\n"
> for i in range(0,100000):
> fh.write(testline)
> fh.close()
>
I do not know if this is cause, but Maxima's print is not the same as
Python's write. Print has to convert the internal format of the list to
a suitable output form, possibly also checking to see how to do a nice
2D display.
Ray