On Wed, 9 Dec 2020 02:01:58 +1100 Chris Angelico firstname.lastname@example.org wrote:
On Tue, Dec 8, 2020 at 11:05 PM Paul Sokolovsky email@example.com wrote:
It'd be best to just write what you want directly, using the tools in importlib.
Of course, the implementation of the above for CPython would be based on importlib. And other implementations could implement that "directly", for the background idea of it being how to implement import hooks as frugally as possible, and easily allow to do most of what could be wanted of single-file import hooking.
Have you tried to just write this as-is? Python already offers a number of tools. Try writing it using the existing tools and see if this even needs to be a proposal.
I have written this (what my initial mail talks about) for both Pycopy and CPython. Now I wonder if I shouldn't really follow "the most minimal possible implementation" (the usual Pycopy criteria) and upgrade API a just little bit. Likely, the code byte count will still decide, but I'd like to get a second opinion from usability PoV, etc.