(fxn:Callable)
| 1266 | return res |
| 1267 | |
| 1268 | def deconstruct_function(fxn:Callable) -> tuple: |
| 1269 | new_globals = {k:v for k,v in fxn.__globals__.items() if k in fxn.__code__.co_names} |
| 1270 | for co in fxn.__code__.co_consts: |
| 1271 | if isinstance(co, types.CodeType): new_globals.update({k:v for k,v in fxn.__globals__.items() if k in co.co_names}) |
| 1272 | # NOTE: optional round trip through pickle! |
| 1273 | assert fxn.__closure__ is None, "closures are not supported in pattern matchers" |
| 1274 | ret = fxn.__code__, new_globals, fxn.__name__, fxn.__defaults__ |
| 1275 | return pickle.loads(pickle.dumps(ret)) if getenv("TEST_PICKLE") else ret |
| 1276 | |
| 1277 | @functools.cache |
| 1278 | def upat_interpret(p:UPat, fxn:Callable) -> Callable: |
no test coverage detected
searching dependent graphs…