3 ms·
Python has API that allows you to replace parts of import system with arbitrary Python code.
by dfox 7y ago
Python 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