I'm not fundamentally opposed to the patch, but what's the difference between:
global['global_func'] = some_func
locals['self'] = some_object
compiled, _ = rewrite_and_compile(code,
output_func_name='global_func', output_func_self='self')
exec compiled in locals, globals
And
locals['local_func'] = lambda *args: some_func(some_object, *args)
compiled, _ = rewrite_and_compile(code, output_func_name=local_func)
exec compiled in locals, globals
Also, why would multiple threads would be sharing the same global
scope? (There are obviously cases where that happens, like when
multiple threads are using the same module. But I wouldn't expect one
to use the compiled result of rewrite.py with the global scope of a
module.)
- Owen