Browse Source

Use hasattr instead of dir

`dir()` is insanely slow since it has to create and sort a list each time. Switching to `hasattr` provides a nice 10x speedup.
pull/59/head
Nathan Villaescusa 11 years ago
parent
commit
fdb1b18f14
  1. 2
      pygal/graph/base.py

2
pygal/graph/base.py

@ -70,7 +70,7 @@ class BaseGraph(object):
def __getattr__(self, attr):
"""Search in config, then in self"""
if attr in dir(self.config):
if hasattr(self.config, attr):
return object.__getattribute__(self.config, attr)
return object.__getattribute__(self, attr)

Loading…
Cancel
Save