def _get_function_globals_for_reduction(func):
 func_id = bytecode.FunctionIdentity.from_function(func)
 bc = bytecode.ByteCode(func_id)
 globs = bc.get_used_globals()
 for (k, v) in globs.items():
  if isinstance(v, ModuleType):
   globs[k] = _ModuleRef(v.__name__)
 globs['__name__'] = func.__module__
 return globs

def _get_function_globals_for_reduction ( func ) : func_id = bytecode . FunctionIdentity . from_function ( func ) bc = bytecode . ByteCode ( func_id ) globs = bc . get_used_globals ( ) for ( k , v ) in globs . items ( ) : if isinstance ( v , ModuleType ) : globs [ k ] = _ModuleRef ( v . __name__ ) globs [ '__name__' ] = func . __module__ return globs
analyse *func* and return a dictionary of global values suitable for reduction .