On Tue, Sep 5, 2017 at 7:42 AM, Neil Girdhar <mistersheik@gmail.com> wrote:
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.

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.

--Guido van Rossum (python.org/~guido)