I'm currently working on speeding up the legend rendering of matplotlib
as this turns out to be a bottleneck for my application. With some
tracing and profiling, I found that
matplotlib.__init__.RcParams.__getitem__() makes up around 10% of the
total function calls (by number) in my little test program. It is called
continuously all over the matplotlib code, whenever a configuration
parameter is accessed.
Therefore removed the __getitem__ method and moved the key validation to
a newly written __init__ function, so that validation only happens once
the object is created, and otherwise the native lookup of the dict()
class is used. This made my program around 10% faster!
The diff ("svn diff") is appended. If you are interested in the
profiling results (not only regarding this piece of code), please let me
Hope that helps!
matplotlib.diff (2.11 KB)