3 ms·
Is there a guide/overview/doc/tutorial/whatever of how Hy is implemented? I'm curious how hy modules can be imported in python directly.
by maest 7y ago
Is there a guide/overview/doc/tutorial/whatever of how Hy is implemented?
I'm curious how hy modules can be imported in python directly.
- dfox 7y agoPython has API that allows you to replace parts of import system with arbitrary Python code.
- maest 7y agoIf 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)
- greenshackle2 7y agoI think you are correct, they monkey-patched importlib https://github.com/hylang/hy/blob/master/hy/importer.py#L132 https://github.com/hylang/hy/blob/master/hy/importer.py#L132
- btwillard 7y agoAs 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. https://github.com/hylang/hy/pull/1672 https://github.com/hylang/hy/pull/1672