Profiling Python with cProfile
yrmichael.com
Profiling Python with cProfile
1–10 of 19 posts
Re: Profiling Python with cProfile
#2Re: Profiling Python with cProfile
#3Re: Profiling Python with cProfile
#4You'll perhaps take this as snark, but I am not going to read light gray text on a white background with a poorly rendered font (windows 7, firefox 27, 47yo eyes).
Re: Profiling Python with cProfile
#5You'll perhaps take this as snark, but I am not going to read light gray text on a white background with a poorly rendered font (windows 7, firefox 27, 47yo eyes).
Re: Profiling Python with cProfile
#6Re: Profiling Python with cProfile
#7Very helpful to have a UI for digging through profiler results. I use the django debug toolbar but I think your profiler will be incredibly helpful for finding bottlenecks. Thanks for posting, thanks for sharing.
Re: Profiling Python with cProfile
#8Re: Profiling Python with cProfile
#9In python function/method calls are expensive, so avoid them at all costs inside tight loops.
Re: Profiling Python with cProfile
#10I'd say you had it right the first time with the list comprehension. List comprehensions in python are way faster than while/append loops because they're implemented in C. The issue is that you had the "not in" which is O(n) over a list (making the comprehension O(n^2) ). If the documents are hashable, I'd suggest making results a set. "not in" is constant time on a set. If a document is something not hashable, you c…
Function calls in tight loops are a killer. Property and global lookups are also "much" less efficient than stuff in the local scope.