MCPcopy
hub / github.com/tinygrad/tinygrad / _serialize_code

Function _serialize_code

tinygrad/helpers.py:581–583  ·  view source on GitHub ↗
(code:types.CodeType)

Source from the content-addressed store, hash-verified

579
580def _reconstruct_code(*args): return types.CodeType(*args)
581def _serialize_code(code:types.CodeType):
582 args = inspect.signature(types.CodeType).parameters # NOTE: this works in Python 3.10 and up
583 return _reconstruct_code, tuple(code.__getattribute__('co_'+x.replace('codestring', 'code').replace('constants', 'consts')) for x in args)
584copyreg.pickle(types.CodeType, _serialize_code)
585
586def _serialize_module(module:types.ModuleType): return importlib.import_module, (module.__name__,)

Callers

nothing calls this directly

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…