<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>On Jan 27, 2016, at 12:20, Brett Cannon <<a href="mailto:brett@python.org">brett@python.org</a>> wrote:</div><div><br></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, 27 Jan 2016 at 08:49 Andrew Barnert via Python-ideas <<a href="mailto:python-ideas@python.org">python-ideas@python.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
If someone builds a transformer that only runs on files with a different extension, he already needs an import hook, so he might as well just call his transformer from the input hook, same as he does today.<br></blockquote><div><br></div><div>And the import hook is not that difficult. </div></div></div></div></blockquote><div><br></div><div>Unless it has to work in 2.7 and 3.3 (or, worse, 2.6 and 3.2). :)</div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_quote"><div>You can reuse everything from importlib without modification except for needing to override a single method in some loader to do your transformation </div></div></div></div></blockquote><div><br></div><div>Yes, as of 3.4, the design is amazing. In fact, hooking any level--lookup, source, AST, bytecode, or pyc--is about as easy as it could be.</div><div><br></div><div>My only complaint is that it's not easy enough to find out how easy import hooks are. When I tell people "you could write a simple import hook to play with that idea", they get a look of fear and panic that's completely unwarranted and just drop their cool idea. (I wonder if having complete examples of a simple global-transformer hook and a simple special-extension hook at the start of the docs would be enough to solve that problem?)</div><div><br></div><div>And I'm a bit worried that if Victor tries to make things like MacroPy and Hy easier, it still won't be enough for real-life cases, so all it'll do is discourage people from going right to writing import hooks and seeing how easy that already is.</div></body></html>