Printing to file, how do I do it efficiently?
cameron.walsh at gmail.com
Fri Nov 10 09:09:49 CET 2006
Robert Kern wrote:
> Cameron Walsh wrote:
>> Hi all,
>> I have a numpy.array of 89x512x512 uint8's, set up with code like this:
> numpy questions are best asked on the numpy list, not here.
At first I thought it was a generic python question, since it had more
to do with writing array data to file rather than the specific format of
the array data.
> You might want to look at using numpy.empty() here, instead.
>> I'm guessing that the slow part is the fact that I am converting the
>> data to character format and writing it one character at a time. What
>> is a better way of doing this, or where should I look to find a better way?
And here I see I was wrong, it was a numpy question. I assumed the
tostring() method would produce the same output as printing the array to
the screen by just calling "data". But of course, that would be the job
of the __repr__() method.
It is now ridiculously fast (<1second). Thank you for your help.
More information about the Python-list