well some of your safety concerns can be allayed, i hope, by replacing this snipet:
>>> frmglobals = func.__globals__.copy()
>>> ret= func(*args, **kwargs)
with this one:
>>> with _modifyGlobals(func.__globals__, localArgs):
>>> ret = func(*args, **kwargs)
with _modifyGlobals defined as:
>>>from contextlib import contextmanager
>>>def _modifyGlobals(glbls, additions):
>>> frmglbls = glbls.copy()
as for performance you are correct that it is more efficient to just use global variables.
the dictionary updates add about 1 x 10**-4 (or, if the check for collisions with KWargs is removed, 5 x 10**-5)
seconds to the run time of a function, at least on this computer.
so not terribly significant just be sure to use sparingly
also with the link you mentioned i could not seem to get it to work. Whenever i tried to use any built-in functions
it would start throwing NameErrors. also that is only useful if you want to inject all global variables into the function.