why huge speed difference btwn 1.52 and 2.1?

Aahz Maruch aahz at panix.com
Tue Jun 5 13:29:27 EDT 2001


In article <3b1bcf7a.12528354 at news.ccs.queensu.ca>,
Robin Senior <rsenior at hotmail.com> wrote:
>
>		for state in states.keys():
>			#(STATENAME) OR (STATE ABBREVIATION)
>			if ( (re.search(' '+state+'( |,)', line, re.IGNORECASE)) or (re.search(' '+states[state]+'( |,)', line, re.IGNORECASE)) ):
>				filename = string.replace(state, ' ', '_')
>				g = open('states/'+filename+'/'+str(year)+'.TXT', "a")
>				g.write(line)
>				g.write("\n")
>				g.close()
>	f.close()

In addition to the other comments you've received, you should probably
move the g.open() outside this loop.
-- 
                      --- Aahz  <*>  (Copyright 2001 by aahz at pobox.com)

Hugs and backrubs -- I break Rule 6                 http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista   

"Do not taunt happy fun for loops. Do not change lists you are looping over."
--Remco Gerlich, comp.lang.python



More information about the Python-list mailing list