From: Stefan Behnel Date: Fri, 3 Jul 2009 20:20:16 +0000 (+0200) Subject: reduce code-gen time spent in builtins X-Git-Tag: 0.12.alpha0~276 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fc3d5fea2213cf303065c42f0b5d056ea0477f1f;p=cython.git reduce code-gen time spent in builtins --- 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)