reduce code-gen time spent in builtins
authorStefan Behnel <scoder@users.berlios.de>
Fri, 3 Jul 2009 20:20:16 +0000 (22:20 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 3 Jul 2009 20:20:16 +0000 (22:20 +0200)
Cython/Compiler/Code.py

index a1dce43243016aaa0929693d0eac080cb7f1a3c5..81d8d96402ffc7ea36df054c245663924037c81c 100644 (file)
@@ -723,8 +723,15 @@ class GlobalState(object):
 
 
 def funccontext_property(name):
+    try:
+        import operator
+        attribute_of = operator.attrgetter(name)
+    except:
+        def attribute_of(o):
+            return getattr(o, name)
+
     def get(self):
-        return getattr(self.funcstate, name)
+        return attribute_of(self.funcstate)
     def set(self, value):
         setattr(self.funcstate, name, value)
     return property(get, set)