[Python-ideas] Replace option set/get methods through the standard library with a ChainMap; add a context manager to ChainMap
mistersheik at gmail.com
Sat Sep 14 22:10:00 CEST 2013
ChainMap supports the pattern of a "dictionary that supports temporarily
overriding items". The method I'm suggesting is as follows:
def child_contex(self, **kwargs):
self = self.parents
Then, when updating numpy.printoptions:
... # do something
With a regular dict, numpy would end up implementing the necessary context
manager once for each set of options instead of factoring that code out
On Thu, Sep 12, 2013 at 6:24 AM, Oscar Benjamin
<oscar.j.benjamin at gmail.com>wrote:
> On 12 September 2013 11:14, Neil Girdhar <mistersheik at gmail.com> wrote:
> > Thank you. I will ask there about adding numpy context managers.
> > the extra member function to ChainMap to use it as a context manager
> > be a question for this mailing list, right?
> Perhaps you could spell out that part of the idea in more detail then.
> Why in particular would it need to be a ChainMap and not a regular
> dict? Does the method return a new ChainMap instance? What would be
> seen by other code that holds references to the same ChainMap?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas