summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichele Simionato <michele.simionato@gmail.com>2015-12-09 08:58:38 +0100
committerMichele Simionato <michele.simionato@gmail.com>2015-12-09 08:58:38 +0100
commitf22e94ae1bcf816328c2ee9b5e41a32276e32b30 (patch)
treebb654014850fcdd379e11c79fa0d4b23f66b5559 /src
parentd6abda047e0b52aa1a379d06bd700edda8c623b7 (diff)
downloadpython-decorator-git-f22e94ae1bcf816328c2ee9b5e41a32276e32b30.tar.gz
Avoided copying the globals
Diffstat (limited to 'src')
-rw-r--r--src/decorator.py8
1 files changed, 2 insertions, 6 deletions
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__,