Python string formatting too slow
Posted
by wich
on Stack Overflow
See other posts from Stack Overflow
or by wich
Published on 2010-04-14T13:03:41Z
Indexed on
2010/04/14
16:13 UTC
Read the original article
Hit count: 243
I use the following code to log a map, it is fast when it only contains zeroes, but as soon as there is actual data in the map it becomes unbearably slow... Is there any way to do this faster?
log_file = open('testfile', 'w')
for i, x in ((i, start + i * interval) for i in range(length)):
log_file.write('%-5d %8.3f %13g %13g %13g %13g %13g %13g\n' % (i, x,
map[0][i], map[1][i], map[2][i], map[3][i], map[4][i], map[5][i]))
© Stack Overflow or respective owner