Re:A week with Hy
by dfox on Thursday August 08, 2019 @01:51PM
(#20646780)
Python has API that allows you to replace parts of import system with arbitrary Python code.
[ Parent
| on HN ]
If you are talking about the import hooks, I think those require the imported file to have valid python syntax. The import hooks work on the python AST (I think)
Re:A week with Hy
by greenshackle2 on Thursday August 08, 2019 @05:48PM
(#20649171)
I think you are correct, they monkey-patched importlib
https://github.com/hylang/hy/blob/master/hy/importer.py#L132
As I recall, patching was simply the most expedient approach. Otherwise, for the changes we needed to make, we would've had to copy a lot of source from the standard loader implementation in CPython for only a few simple changes.