code: def extract_code_globals(cls, co):
          
          out_names = cls._extract_code_globals_cache.get(co)
          if out_names is None:
              try:
                  names = co.co_names
              except AttributeError:
                  # PyPy "builtin-code" object
                  out_names = set()
              else:
                  out_names = set(names[oparg]
                                  for op, oparg in _walk_global_ops(co))
  
                  # see if nested function have any global refs
                  if co.co_consts:
                      for const in co.co_consts:
                          if type(const) is types.CodeType:
                              out_names |= cls.extract_code_globals(const)
  
              cls._extract_code_globals_cache[co] = out_names
  
          return out_names
docs: Find all globals names read or written to by codeblock co