Hi,

First of all thanks everyone for the tips!
I tried some of the ideas and found that although both string formatting 
and line-by-line writing did affect file output speed a bit it was the 
code structure that affected the most.
I had some MDoubleArray, MVectorArray, MRenderLine variable definitions 
inside the loop that I could remove, and it had much greater effect than 
I would have anticipated.
But at least I learned some cool python tricks!

> Wonder if the modulo is causing you timing issues?
Very small difference.
> Actually, you know, it might be the constant open and close  of the file.
The file was not opened separately for each fprint statement, sorry, I 
left the open/close part out of the example.

Its a completely different issue but something that still bothers me a 
bit is that the purpose of this code was to create a python API version 
of the pfxstrokes command, both for learning python bits and as the 
basis of an exporter. And even though it works nicely the python version 
completes in 25 seconds while the original command does in 3. And the 
file output is now lightning fast... :)

Cheers,
Szabolcs


lutz.paelike wrote:
> You should gather your lines in a buffer and write more then one line
> at once.
> The best way would be to add each line to a list first, concat them
> with a linefeed character
> and then write them to disk in one call. If memory consumption is a
> issue you could write each
> 100 or each 1000 lines... and the clear the list again
>
>   


--~--~---------~--~----~------------~-------~--~----~
Yours,
Maya-Python Club Team.
-~----------~----~----~----~------~----~------~--~---

Reply via email to