From fc3d5fea2213cf303065c42f0b5d056ea0477f1f Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 3 Jul 2009 22:20:16 +0200 Subject: [PATCH] reduce code-gen time spent in builtins --- Cython/Compiler/Code.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/Code.py b/Cython/Compiler/Code.py index a1dce432..81d8d964 100644 --- a/Cython/Compiler/Code.py +++ b/Cython/Compiler/Code.py @@ -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) -- 2.26.2