python disk i/o speed
pruebauno at latinmail.com
Fri Aug 9 16:50:49 CEST 2002
"Delaney, Timothy" <tdelaney at avaya.com> wrote in message news:<mailman.1028765472.4175.python-list at python.org>...
> > From: pruebauno at latinmail.com [mailto:pruebauno at latinmail.com]
> I can spot a few immediate problems:
> 2. You are using string concatenation for both the Python and java code.
> This is bad for performance (a new string needs to be created every time.
> This is almost certainly downing out the I/O characteristics.
> # formatting
> out = '"%s","%s","%s","%s"\n' % (part0, part1, part2,
> As you can see, formatting is much clearer, and is probably going to be
> fastest in this case (everything is done in C code).
> Java options: Use a StringBuffer or java.text.MessageFormat (effectively
> string formatting). I'll leave the code up to you. It's less pretty.
> Tim Delaney
I can´t reproduce your claimings in practice.
out.write('"%s","%s","%s","%i"\n' % (
x,y,z,localint(x) + localint(y) + localint(z)))
localint(x) + localint(y) + localint(z))+'"\n')
and my programm finished a half-second faster, which doesn´t make
sense to me, since there is an additional str() call involved. I
tought it would slow things down.
I think the greatest performance benefit would have been just the
which wasn´t doing anything usefull anyway. :)
Test it out yourself.
More information about the Python-list