(self, func)
return (code, f_globals, defaults, closure, dct, base_globals)
Turn the function into a tuple of data necessary to recreate it:
            code, globals, defaults, closure_values, dict
Turn the function into a tuple of data necessary to recreate it:
            code, globals, defaults, closure_values, dict
Turn the function into a tuple of data necessary to recreate it : code globals defaults closure_values dict
def extract_func_data(self, func):
        """
        Turn the function into a tuple of data necessary to recreate it:
            code, globals, defaults, closure_values, dict
        """
        code = func.__code__

        # extract all global ref's
        func_global_refs = _extract_code_globals(code)

        # process all variables referenced by global environment
        f_globals = {}
        for var in func_global_refs:
            if var in func.__globals__:
                f_globals[var] = func.__globals__[var]

        # defaults requires no processing
        defaults = func.__defaults__

        # process closure
        closure = (
            list(map(_get_cell_contents, func.__closure__))
            if func.__closure__ is not None
            else None
        )

        # save the dict
        dct = func.__dict__

        # base_globals represents the future global namespace of func at
        # unpickling time. Looking it up and storing it in globals_ref allow
        # functions sharing the same globals at pickling time to also
        # share them once unpickled, at one condition: since globals_ref is
        # an attribute of a Cloudpickler instance, and that a new CloudPickler is
        # created each time pickle.dump or pickle.dumps is called, functions
        # also need to be saved within the same invokation of
        # cloudpickle.dump/cloudpickle.dumps (for example: cloudpickle.dumps([f1, f2])). There
        # is no such limitation when using Cloudpickler.dump, as long as the
        # multiple invokations are bound to the same Cloudpickler.
        base_globals = self.globals_ref.setdefault(id(func.__globals__), {})

        if base_globals == {}:
            # Add module attributes used to resolve relative imports
            # instructions inside func.
            for k in ["__package__", "__name__", "__path__", "__file__"]:
                # Some built-in functions/methods such as object.__new__  have
                # their __globals__ set to None in PyPy
                if func.__globals__ is not None and k in func.__globals__:
                    base_globals[k] = func.__globals__[k]

        return (code, f_globals, defaults, closure, dct, base_globals)
def extract_func_data ( self , func ) : code = func . __code__ # extract all global ref's func_global_refs = _extract_code_globals ( code ) # process all variables referenced by global environment f_globals = { } for var in func_global_refs : if var in func . __globals__ : f_globals [ var ] = func . __globals__ [ var ] # defaults requires no processing defaults = func . __defaults__ # process closure closure = ( list ( map ( _get_cell_contents , func . __closure__ ) ) if func . __closure__ is not None else None ) # save the dict dct = func . __dict__ # base_globals represents the future global namespace of func at # unpickling time. Looking it up and storing it in globals_ref allow # functions sharing the same globals at pickling time to also # share them once unpickled, at one condition: since globals_ref is # an attribute of a Cloudpickler instance, and that a new CloudPickler is # created each time pickle.dump or pickle.dumps is called, functions # also need to be saved within the same invokation of # cloudpickle.dump/cloudpickle.dumps (for example: cloudpickle.dumps([f1, f2])). There # is no such limitation when using Cloudpickler.dump, as long as the # multiple invokations are bound to the same Cloudpickler. base_globals = self . globals_ref . setdefault ( id ( func . __globals__ ) , { } ) if base_globals == { } : # Add module attributes used to resolve relative imports # instructions inside func. for k in [ "__package__" , "__name__" , "__path__" , "__file__" ] : # Some built-in functions/methods such as object.__new__  have # their __globals__ set to None in PyPy if func . __globals__ is not None and k in func . __globals__ : base_globals [ k ] = func . __globals__ [ k ] return ( code , f_globals , defaults , closure , dct , base_globals )