speed problems

Neal Holtz nholtz at docuweb.ca
Wed Jun 9 11:28:36 EDT 2004


"^" <axel at axel.truedestiny.net> wrote in message news:<qFGvc.3023$xm1.935 at amsnews05.chello.com>...
> Hi group,
> 
> I've become interested in Python a while ago and just converted a simple
> perl script to python. The script is very simple, it generates a list of
> found virusses from some maillog files for further processing.
> I've found that there's a huge difference in execution time for the scripts,
> in favor of perl and I can't pinpoint what's going wrong;
> . . .
> Thanks for any help you can provide,
> Kind regards,
> 
> Axel

I've halved the python time on my test by changing the entire inner loop
to:

        pat = re.compile( "MALWARE:\s+(.*)" )
        for line in lf:
            mo = pat.search( line )
            if mo:
                for vnam in mo.group(1).split( ", "):
                    virstat[vnam] = virstat.get(vnam,0) + 1
                    total += 1
        lf.close()

(with changes form my logfile format):

Of course, its no longer the same as the perl version, and
the perl version would also probably benefit from something
similar.



More information about the Python-list mailing list