From f22e94ae1bcf816328c2ee9b5e41a32276e32b30 Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Wed, 9 Dec 2015 08:58:38 +0100 Subject: Avoided copying the globals --- src/decorator.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/decorator.py b/src/decorator.py index 05f7056..a8c22e7 100644 --- a/src/decorator.py +++ b/src/decorator.py @@ -225,9 +225,7 @@ def decorate(func, caller): """ decorate(func, caller) decorates a function using a caller. """ - evaldict = func.__globals__.copy() - evaldict['_call_'] = caller - evaldict['_func_'] = func + evaldict = dict(_call_=caller, _func_=func) fun = FunctionMaker.create( func, "return _call_(_func_, %(shortsignature)s)", evaldict, __wrapped__=func) @@ -258,9 +256,7 @@ def decorator(caller, _func=None): name = caller.__class__.__name__.lower() callerfunc = caller.__call__.__func__ doc = caller.__call__.__doc__ - evaldict = callerfunc.__globals__.copy() - evaldict['_call_'] = caller - evaldict['_decorate_'] = decorate + evaldict = dict(_call_=caller, _decorate_=decorate) return FunctionMaker.create( '%s(func)' % name, 'return _decorate_(func, _call_)', evaldict, doc=doc, module=caller.__module__, -- cgit v1.2.1