<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace"><span style="font-family:arial,sans-serif">On Tue, Sep 12, 2017 at 6:30 PM, Koos Zevenhoven </span><span dir="ltr" style="font-family:arial,sans-serif"><<a href="mailto:k7hoven@gmail.com" target="_blank">k7hoven@gmail.com</a>></span><span style="font-family:arial,sans-serif"> wrote:</span><br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><span class="gmail-"><div style="font-family:monospace,monospace"><span style="font-family:arial,sans-serif">On Tue, Sep 12, 2017 at 5:53 PM, Stefan Krah </span><span dir="ltr" style="font-family:arial,sans-serif"><<a href="mailto:stefan@bytereef.org" target="_blank">stefan@bytereef.org</a>></span><span style="font-family:arial,sans-serif"> wrote:</span><br></div></span><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>On Tue, Sep 12, 2017 at 05:35:34PM +0300, Koos Zevenhoven wrote:<br>
> I don't see how the situation benefits from calling something the "main<br>
> interpreter". Subinterpreters can be a way to take something<br>
> non-thread-safe and make it thread-safe, because in an<br>
> interpreter-per-thread scheme, most of the state, like module globals, are<br>
> thread-local. (Well, this doesn't help for async concurrency, but anyway.)<br>
<br>
</span>You could have a privileged C extension that is only imported in the main<br>
interpreter:<br>
<br>
<br>
if get_current_interp() is main_interp():<br>
    from _decimal import *<br>
else:<br>
    from _pydecimal import *<br>
<br>
<br></blockquote><div><br></div></span></div></div></div></blockquote><div><br></div><div><div class="gmail_default" style="font-family:monospace,monospace">​​Oops.. it should of course be "by_this_process", not "by_other_process" (fixed below).​​</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-"><div></div></span><div><div style="font-family:monospace,monospace">​Or it could be first-come first-served:</div><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace">if is_imported_by_<div class="gmail_default" style="font-family:monospace,monospace;display:inline">​this</div>_process("<wbr>_decimal"):<div class="gmail_default" style="font-family:monospace,monospace;display:inline">​​</div><span style="font-family:arial,sans-serif"> </span></div></div></div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div style="font-family:monospace,monospace"></div><div style="font-family:monospace,monospace">    from _pydecimal import *</div><div style="font-family:monospace,monospace">else</div><div style="font-family:monospace,monospace">    from _decimal import *</div><span class="gmail-HOEnZb"><font color="#888888"><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace">––Koos</div><br></font></span></div><div><br></div><div><br></div></div><span class="gmail-">-- <br><div class="gmail-m_9174548400113236750gmail_signature">+ Koos Zevenhoven + <a href="http://twitter.com/k7hoven" target="_blank">http://twitter.com/k7hoven</a> +</div>
</span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">+ Koos Zevenhoven + <a href="http://twitter.com/k7hoven" target="_blank">http://twitter.com/k7hoven</a> +</div>
</div></div>