memoize open_script

This commit is contained in:
2022-05-10 10:40:53 +02:00
parent 9e0108f5fe
commit ecc53f0697

View File

@ -3,6 +3,7 @@
from glob import glob
from io import StringIO
from contextlib import redirect_stdout, redirect_stderr
from functools import lru_cache
import http.server
import socketserver
@ -49,7 +50,10 @@ def run_script(fn):
exec(code)
return sio.getvalue()
@lru_cache()
def open_script(fn):
print("reading", fn)
print("_" * 80)
with open(fn) as f:
src = f.read()
code = compile(src, fn, "exec")