python disk i/o speed
tdelaney at avaya.com
Thu Aug 8 02:10:29 CEST 2002
> From: pruebauno at latinmail.com [mailto:pruebauno at latinmail.com]
I can spot a few immediate problems:
1. In the Python code, you are never closing the file. Always explicitly
close the file.
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.
Python options: use string formatting or list joining.
out = [
out = '"' + '","'.join(out) + '"\n'
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.
More information about the Python-list