Hi,
I use python 2.4.4, py2exe 0.6.9,  windows XP.
 
I totally agree with you that I should of come up with a test case. First of all by program is very large, lots of code. I also indeed from my code copy out the bit where I write to file and create a small program with a single loop over writing 200 times to file. Created a .py file and an .exe with py2exe. Both were writing fast to file with no problem. If it sounded as I said that the py2exe make writing to file slow, I apologise for that. Its just that in the "big" program that I have experienced that it is slow.. I used the profile and it gave me like 0.024 seconds for the close command. I did not do a profiling of .py and .exe, but I can see it is slow. With a print statement, I can just see that the .py is like 10 times faster with open, write and close. I removed the open write close, and I see the print statement very fast again showing that it is there. I just think it might be a combination of factors that causes it to become slow, I can't reproduce it by making a small script where I just open write close. So, I am actually also clueless. I was just wondering if anyone might have experienced something like that and have solved it. Or have any idea on what I can sort out more to tackle the problem. Thanks in advance.
meneer
 

--- On Sat, 8/1/09, Daryl Tester <dt-py2exe@handcraftedcomputers.com.au> wrote:

From: Daryl Tester <dt-py2exe@handcraftedcomputers.com.au>
Subject: Re: [Py2exe-users] file open close very slow
To: "py2exe" <py2exe-users@lists.sourceforge.net>
Date: Saturday, August 1, 2009, 1:06 PM

Robert Robert wrote:
> Hi All,
> I have a py script in which in a loop I create new files as
> fp = open( filenam, "w")
> When I run it normally like from IDle, it run fast. Then I decide to
> make a .exe of it using py2exe and all of a sudden it takes a lots of
> time to write to file. Its a larger program then smply writing to file.
> So to confirm that it is writing to file that is so slow, I remove only
> the open and close , so I don't write to file anymore, and the .exe was
> very fast. I put the code back and it was slow again. I am clueless
> about what this could cause the problem. Any suggestion ? What does
> py2exe do with the open and write of files ?
> meneer

Given Python 2.5.2, py2exe 0.6.8, XP under VMware and the following setup:

from distutils.core import setup
import py2exe
import sys

setup(console=["opentest.py"])

and file "opentest.py":

import timeit

filename = r'C:\Documents and Settings\dt\Local Settings\Temp\testfile.txt'

def opentest(fname):
    f = open(fname, 'w')
    f.write("fnord\n")
    f.close()

if __name__ == '__main__':
    t = timeit.Timer("opentest(filename)", \
            "from __main__ import opentest, filename")
    print t.timeit(10000)

I get:

C:\Documents and Settings\dt\My Documents>opentest.py
5.47282657433

C:\Documents and Settings\dt\My Documents>dist\opentest.exe
5.43320505818

seconds respectively.

If you think there is an issue, perhaps as a bare minimum you should come up
with version numbers, timings and a reproducible test case?

--
Regards,
  Daryl Tester

"Crush! Kill! Deploy!"  -- Lost In Space I.T. Dept.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Py2exe-users mailing list
Py2exe-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/py2exe-users