Repository navigation
loader: assorted fixes - #222
Conversation
|
@alexcrichton I have a prototype of an importlib loader for components that builds on top of these fixes but I'll probably hold off submitting it until you've had a chance to review #221 and #222. |
There's basically no reason to do this as nothing in Python ecosystem attempts to load `.wasm` or `.wat` files except for wasmtime, and it is [recommended] in the docs to use `.append()` for adding a finder. [recommended]: https://docs.python.org/3/library/importlib.html#setting-up-an-importer
This approach has the advantage of not having the `func` argument in the signature of the method, which is visible in e.g. `help()`.
The `spec_from_file_location` helper includes a lot of indirection and code that we really don't care about; creating the right `ModuleSpec` directly here makes the semantics obvious.
|
Rebased. |
|
Thank you very much for this! All looks great to me and I'm glad this has a better pair of eyes on it than my own "not very Python trained" eyes. |
Honestly, this particular bit of the Python library has almost nobody trained in it, and it's definitely one of the most advanced of advanced topics any Python programmer will ever explore, save for perhaps the more obscure FFI-related ones. It was really quite difficult for me to get my head around it, partly due to how obscure it is, partly due to the peculiar state of the docs, and I've spent basically a workday or two reading sources of the Python internals and comparing them across versions. |
|
IIRC the initial bits here were copy/pasted from assorted blogs/stack overflow posts, so I suspect you've done much more studying already than I initially did! |
Depends on #221.
This is an incremental but substantial improvement, to the point where I'd say I consider this implementation correct, or very close to correct, according to my understanding of the importlib hooks involved.
It is however still not thread-safe, I will likely address that after adding component support.