speedup up dictionary access
Roy Smith
roy at panix.com
Sat May 12 17:42:40 EDT 2001
aahz at panix.com (Aahz Maruch) wrote:
> >One of the big time consumers in an application I'm writing is a cache
> >lookup in the inner loop of the program.
>
> How do you know that?
That's what the profiler says (or at least the profiler says the function
which contains that, and not much else, is the culprit). I suppose I could
in-line the function, but that would be very messy, since it's called from
many different places.
> That will be a tiny bit faster than the 'if', but not enough to make a
> difference if the cache lookup is really the problem. You should
> probably spend some time thinking about the work you're actually trying
> to accomplish and whether you're going about it the right way.
Well, actually, I did spend some time thinking about it, and that's when I
hit upon the idea of the cache, which won me almost a 10x speedup. Now I'm
looking for more :-)
More information about the Python-list
mailing list