<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 class=""></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 class=""></span></div></blockquote><div><br></div><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><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>