From fdb1b18f140e21d9a856ef0b70af8e31d638c4c1 Mon Sep 17 00:00:00 2001 From: Nathan Villaescusa Date: Mon, 9 Sep 2013 14:52:47 -0700 Subject: [PATCH] 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. --- pygal/graph/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygal/graph/base.py b/pygal/graph/base.py index cc45cec..6cacbeb 100644 --- a/pygal/graph/base.py +++ b/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)