Reading files

I’ve been working on a file parser, and have seen something I don’t quite understand.

If I read and write a file line by line, it takes much longer within the fpmi environment than within a python IDE (such as SPE). I’ve removed other code, and isolated it down to that. Here’s a sample of what I’m doing:

import re
import os

tInData = open('C:\\TestFolder\\', 'rb')
tOutData = open('tempoutfile', 'w')

for line in tInData.readlines():

Using a file of around 1mb, it takes about 5 seconds to copy the file to tOutData within fpmi, but under a second with SPE. Can you think of a reason for this? I think you guys use Python 2.2 within the FPMI framework, and I use 2.6 within my IDE, but I don’t think it should matter since the code is identical, unless the Python compiler is doing something completely different in newer versions.

Also, the difference is definitley related to the write operation. If I just insert ‘PASS’ instead of writing, the time to read the file is the same in both environments (my test files have about 50,000 lines). Don’t waste a lot of time on this, but if you see something obvious that would be great.