<p dir="ltr">You should add <a href="https://bitbucket.org/hipchat/txlocal">https://bitbucket.org/hipchat/txlocal</a> as a reference for the pep as it largely implements this idea for Twisted. It may provide for some practical discussions of use cases and limitations of this approach.</p>
<br><div class="gmail_quote"><div dir="ltr">On Tue, Sep 5, 2017, 09:55 Guido van Rossum <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Sep 5, 2017 at 7:42 AM, Neil Girdhar <span dir="ltr"><<a href="mailto:mistersheik@gmail.com" target="_blank">mistersheik@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span></span>I think you really should add a context manager to PEP 550 since it is better than calling "set", which leaks state. Nathaniel is right that you need set to support legacy numpy methods like seterr. Had there been a way of setting context variables using a context manager, then numpy would only have had to implement the "errstate" context manager on top of it. There would have been no need for seterr, which leaks state between code blocks and is error-prone.<span></span></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>There is nothing in current Python to prevent numpy to use a context manager for seterr; it's easy enough to write your own context manager that saves and restores thread-local state (decimal shows how). In fact with PEP 550 it's so easy that it's really not necessary for the PEP to define this as a separate API -- whoever needs it can just write their own.<br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><br>-- <br><div class="m_2112454891829240304gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div>