Re: Why is this slower?

2009-10-06 Thread Joseph Reagle
nn wrote: > Not only are you doing many function calls but you are assigning 12 > objects each time. Why not do this? > > for bio in bios.values(): > inSRC.add(bio) That obviously makes sense, but I was trying to get away from the verbosity of: inSRC = set([]) inSRC = set([])

Why is this slower?

2009-10-06 Thread Joseph Reagle
I would think the commented code would be faster (fewer loops), but it is not (because of function calls). #Average user_time = 5.9975 over 4 iterations inSRC = set([bio.name for bio in bios.values()]) inEB = set([bio.name for bio in bios.values() if bio.eb_title]) inWP = set([bio

MultiReplace (performance and unordered dicts)

2009-06-04 Thread Joseph Reagle
I have programs that do lots of string-to-string replacements, so I'm trying to create a speedy implementation (tons of .replace statements has become unwieldy). My MultiReplace object does as well as the function regexp, which both do better than the for loop function, any other suggestions? def