<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>On Oct 9, 2014, at 15:21, Nick Coghlan <<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>> wrote:</div><div><br></div><blockquote type="cite"><div><p dir="ltr">
On 10 Oct 2014 00:05, "Nathaniel Smith" <<a href="mailto:njs@pobox.com">njs@pobox.com</a>> wrote:<br>
><br>
> > Valid reasons would be to make it easier for alternative interpreters,<br>
> > or to catch edge cases (e.g. make it work nicely with custom<br>
> > importers, zip files, etc). But at that point, we can just do it the<br>
> > "right way"*, have the backcompat story to a third-party shim.<br>
> ><br>
> > * i.e. "not paying attention to older Pythons" – I'm not saying<br>
> > __new__.py is necessarily the right way, I'm criticizing this reason<br>
> > against it<br>
><br>
> My point is just that it matters whether a backcompat shim is doable. Probably there is some way to implement a backcompat shim for __new__.py, but I don't immediately know how to do it.</p>
<p dir="ltr">Eric Snow already backported the Python 3.4 importlib to Python 2.7 as importlib2, and I know of at least one large company that is planning to deploy that in order to benefit from the directory caching feature. It's a reasonably safe assumption that any future Python 3 import system changes will be made available for Python 2.7 the same way.</p></div></blockquote><div><blockquote type="cite"><div>
<p dir="ltr">That said...</p>
<p dir="ltr">> And again, this is to be compared to the __class__ assignment approach, where we know very well that a backcompat shim is doable because it is done :-).</p>
<p dir="ltr">I actually agree making modules a proxy type that allows setting __class__ on instances is likely the simpler solution here.</p></div></blockquote><div>By "proxy type", you mean that instead of turning off the non-heap flag for ModuleType, we'd just add a (pure Python, or C but not non-heap) ModuleType that delegates to the real one?</div><div><br></div><div>If so, that certainly sounds just as easy to backport to 2.7 with importlib2 as any of the other solutions; no need for ctypes hackery.</div><blockquote type="cite"><div>
<p dir="ltr">You won't get full magic method support, but it *will* enable use of the descriptor protocol for module level attributes.</p>
<p dir="ltr">Cheers,<br>
Nick.<br></p>
<p dir="ltr">><br>
> -n<br>
><br>
><br>
> _______________________________________________<br>
> Python-ideas mailing list<br>
> <a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/python-ideas">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
> Code of Conduct: <a href="http://python.org/psf/codeofconduct/">http://python.org/psf/codeofconduct/</a><br>
</p>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Python-ideas mailing list</span><br><span><a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a></span><br><span><a href="https://mail.python.org/mailman/listinfo/python-ideas">https://mail.python.org/mailman/listinfo/python-ideas</a></span><br><span>Code of Conduct: <a href="http://python.org/psf/codeofconduct/">http://python.org/psf/codeofconduct/</a></span></div></blockquote></div></body></html>