Python example: possible speedup?

Carel Fellinger cfelling at iae.nl
Fri Sep 10 21:40:07 EDT 1999


Carel Fellinger <cfelling at iae.nl> wrote:
> another one. Your code takes almost 7 secs on my machine, mine takes a
> little over 1 sec, and it's still OO and generic. Besides, I didn't use

two small adjustments in the munge_one methods brought it's time just below
the magical 1 sec! so now mine's even more then 7 times faster:)

>     def munge_one(self, package):
> 	name = package['Package']
> 	status = package['Status']
> 	if string.split(status, ' ')[2] == 'installed':

this should read:
        if status[-10:]==' installed':

>     def munge_one(self, package):
> 	name = package['Package']
> 	size = package['Installed-Size']

the above line should go in the body of the next if-statement

> 	if self.installed.has_key(name):
> 	    self.sizes[name] = string.atoi(size)
-- 
groetjes, carel




More information about the Python-list mailing list