@classmethod<EOL><INDENT>def extract_code_globals(cls, co):<DEDENT>
out_names = cls._extract_code_globals_cache.get(co)<EOL>if out_names is None:<EOL><INDENT>try:<EOL><INDENT>names = co.co_names<EOL><DEDENT>except AttributeError:<EOL><INDENT>out_names = set()<EOL><DEDENT>else:<EOL><INDENT>out_names = set(names[oparg]<EOL>for op, oparg in _walk_global_ops(co))<EOL>if co.co_consts:<EOL><INDENT>for const in co.co_consts:<EOL><INDENT>if type(const) is types.CodeType: <EOL><INDENT>out_names |= cls.extract_code_globals(const)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>cls._extract_code_globals_cache[co] = out_names<EOL><DEDENT>return out_names<EOL>
Find all globals names read or written to by codeblock co