[Pythonmac-SIG] Speed issues with Applet/Applications?

Sean Hummel hummelsean@mac.com
Thu, 28 Jun 2001 20:18:30 -0700


on 6/25/01 1:40 AM, Jack Jansen at jack@oratrix.nl wrote:

>> Hi, I wrote a script which allows me to decompress from a .ZIP file, and
>> appropriately sizing names of files that are longer than 31 characters.
>> 
>> However the problem I am encountering, is that when I run the script in the
>> Python IDE, it runs at full speed.  When I run the script as a standalone
>> application or applet, then it runs VERY SLOW!
> 
> I have absolutely no idea what could cause this. Have you tried your script
> under PythonInterpreter in stead of the IDE? Does it then run slow or fast?
> 
> If your script isn't too big (and works with any ZIP file) you can send it to
> me and I can have a look...
> --
> Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
> Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
> www.oratrix.nl/~jack    | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm
> 
> 


Okay here is the script.  It works with any ZIP file as I know it.  However
the problem doesn't seem to show unless you use large files inside of the
ZIP file. (They don't need to be compressed, the same problem shows with
files just in the file for storage.)

------------- CUT HERE ----------------

import zipfile
import string
import sys

# if using the IDE:
filename="Macintosh HD:Desktop Folder:6-0cf3e.zip"
# if built as an application:
# filename=sys.argv[1]

zf=zipfile.ZipFile(filename,"r")
if (zf != None):
    for curfilename in zf.namelist():
        newfilename=curfilename
        if (len(newfilename)>31):
            filen=string.split(newfilename,".")[0]
            filee=string.split(newfilename,".")[1]
            while (len(filen)+len(filee)+1 > 31):
                filen=filen[:-1]
            newfilename=filen+"."+filee
        print curfilename+" --> "+newfilename
        data=zf.read(curfilename)
        outputfile=open(newfilename,"wb")
        outputfile.write(data)
        outputfile.close()
        del data
    zf.close()


print "done..."

------------- CUT HERE-----------------

Now this dearchives an ENTIRE zip file, shortening the "NAME" but preserving
the extension. (Because in my case the extension will be unique, but the
name will be the same, because it is so long.)

Like I said it works fine with small files, but with large files, when built
as an application it runs SLOW, when run in the IDE it runs as one would
expect.