Skip to content

Commit df9ad40

Browse files
committed
1 parent 983be83 commit df9ad40

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

purescripto/purescript_loader.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import ast
1111
import io
1212

13-
1413
class LoadPureScriptImplCode(LoaderForBetterLife[CodeType]):
1514
def source_to_prog(self, src: bytes, path: Path) -> CodeType:
1615
filename = str(path.absolute())
@@ -37,10 +36,22 @@ def dump_program(self, prog: CodeType) -> bytes:
3736
def suffix(self) -> Union[str, Tuple[str, ...]]:
3837
return ".zip.py", ".raw.py"
3938

40-
39+
# to avoid the re-import of a module
40+
# during importing it for the first time.
41+
EXPORTS = {}
4142
def LoadPureScript(file: str, name: str):
43+
cache_key = (file, name)
44+
cache_exports = EXPORTS.get(cache_key)
45+
if cache_exports:
46+
return cache_exports
47+
4248
loader = LoadPureScriptImplCode(file, name)
4349
code = loader.load()
4450
man_made_globals = RTS_TEMPLATE.copy()
4551
exec(code, man_made_globals)
46-
return man_made_globals["exports"]
52+
cache_exports = man_made_globals["exports"]
53+
if cache_key in EXPORTS:
54+
raise Exception("Cross import file {} at {}.".format(file, name))
55+
56+
EXPORTS[cache_key] = cache_exports
57+
return cache_exports

purescripto/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "0.8.8"
1+
__version__ = "0.8.9"
22
__blueprint_version__ = '0.1.3'

0 commit comments

Comments
 (0)