Re: [Python-ideas] PEP draft: context variables

2017-09-05 Thread Neil Girdhar
On Tue, Sep 5, 2017 at 10:54 AM Guido van Rossum wrote: > On Tue, Sep 5, 2017 at 7:42 AM, Neil Girdhar > 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

Re: [Python-ideas] PEP draft: context variables

2017-09-05 Thread Koos Zevenhoven
On Tue, Sep 5, 2017 at 8:43 PM, Yury Selivanov wrote: > On Tue, Sep 5, 2017 at 10:31 AM, Koos Zevenhoven > wrote: > > On Tue, Sep 5, 2017 at 8:24 PM, Yury Selivanov > > wrote: > >> > >> I don't actually care if you use the latest terminology. You seem to > >> have a wrong idea about how PEP 55

Re: [Python-ideas] PEP draft: context variables

2017-09-05 Thread Yury Selivanov
On Tue, Sep 5, 2017 at 10:31 AM, Koos Zevenhoven wrote: > On Tue, Sep 5, 2017 at 8:24 PM, Yury Selivanov > wrote: >> >> On Tue, Sep 5, 2017 at 9:12 AM, Koos Zevenhoven wrote: >> > On Tue, Sep 5, 2017 at 6:53 PM, Yury Selivanov >> > wrote: >> >> >> >> On Tue, Sep 5, 2017 at 8:35 AM, Koos Zevenho

Re: [Python-ideas] PEP draft: context variables

2017-09-05 Thread Koos Zevenhoven
On Tue, Sep 5, 2017 at 8:24 PM, Yury Selivanov wrote: > On Tue, Sep 5, 2017 at 9:12 AM, Koos Zevenhoven wrote: > > On Tue, Sep 5, 2017 at 6:53 PM, Yury Selivanov > > wrote: > >> > >> On Tue, Sep 5, 2017 at 8:35 AM, Koos Zevenhoven > wrote: > >> > On Tue, Sep 5, 2017 at 3:49 AM, Nathaniel Smith

Re: [Python-ideas] PEP draft: context variables

2017-09-05 Thread Yury Selivanov
On Tue, Sep 5, 2017 at 9:12 AM, Koos Zevenhoven wrote: > On Tue, Sep 5, 2017 at 6:53 PM, Yury Selivanov > wrote: >> >> On Tue, Sep 5, 2017 at 8:35 AM, Koos Zevenhoven wrote: >> > On Tue, Sep 5, 2017 at 3:49 AM, Nathaniel Smith wrote: >> [..] >> >> >> >> I think PEP 550 is sufficient to allow im

Re: [Python-ideas] PEP draft: context variables

2017-09-05 Thread Koos Zevenhoven
On Tue, Sep 5, 2017 at 6:53 PM, Yury Selivanov wrote: > On Tue, Sep 5, 2017 at 8:35 AM, Koos Zevenhoven wrote: > > On Tue, Sep 5, 2017 at 3:49 AM, Nathaniel Smith wrote: > [..] > >> > >> I think PEP 550 is sufficient to allow implementing all > >> your proposed APIs (and that if it isn't, that'

Re: [Python-ideas] PEP draft: context variables

2017-09-05 Thread Yury Selivanov
On Tue, Sep 5, 2017 at 8:35 AM, Koos Zevenhoven wrote: > On Tue, Sep 5, 2017 at 3:49 AM, Nathaniel Smith wrote: [..] >> >> I think PEP 550 is sufficient to allow implementing all >> your proposed APIs (and that if it isn't, that's a bug in PEP 550). > > > That's not true either. The LocalContext-

Re: [Python-ideas] PEP draft: context variables

2017-09-05 Thread Koos Zevenhoven
On Tue, Sep 5, 2017 at 10:43 AM, Pavol Lisy wrote: > On 9/4/17, Koos Zevenhoven wrote: > ​[...]​ > > > with cvar.assign(new_value): > > assert cvar.value is new_value > > # Any code here, or down the call chain from here, sees: > > # cvar.value is new_value > >

Re: [Python-ideas] PEP draft: context variables

2017-09-05 Thread Koos Zevenhoven
On Tue, Sep 5, 2017 at 3:49 AM, Nathaniel Smith wrote: > On Mon, Sep 4, 2017 at 2:50 PM, Koos Zevenhoven wrote: > > Hi all, > > > > as promised, here is a draft PEP for context variable semantics and > > implementation. Apologies for the slight delay; I had a not-so-minor > > autosave accident a

Re: [Python-ideas] PEP draft: context variables

2017-09-05 Thread Yury Selivanov
We'll add a reference to the "Can Execution Context be implemented without modifying CPython?" section [1]. However, after skimming through the readme file, I didn't see any examples or limitations that are relevant to PEP 550. If the PEP gets accepted, Twisted can simply add direct support for i

Re: [Python-ideas] PEP draft: context variables

2017-09-05 Thread Jason H
I am a relative nobody in Python, however a few weeks ago, I suggested more harmonization with JavaScript. Admittedly I've been doing more JS lately, so I might have JS-colored glasses on, but it looks like you're trying to add lexical scoping to Python, and there's a whole lot of manual scope w

Re: [Python-ideas] PEP draft: context variables

2017-09-05 Thread Kevin Conway
You should add https://bitbucket.org/hipchat/txlocal 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. On Tue, Sep 5, 2017, 09:55 Guido van Rossum wrote: > On Tue, Sep 5, 2017 at

Re: [Python-ideas] PEP draft: context variables

2017-09-05 Thread Guido van Rossum
On Tue, Sep 5, 2017 at 7:42 AM, Neil Girdhar 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 cont

Re: [Python-ideas] PEP draft: context variables

2017-09-05 Thread Neil Girdhar
On Monday, September 4, 2017 at 6:37:44 PM UTC-4, Yury Selivanov wrote: > > So every generator stores "captured" modifications. This is similar > to PEP 550, which adds Logical Context to generators to store their EC > modifications. The implementation is different, but the intent is the > sa

Re: [Python-ideas] PEP draft: context variables

2017-09-05 Thread Koos Zevenhoven
On Tue, Sep 5, 2017 at 1:20 AM, Oleg Broytman wrote: > Hi! > > On Tue, Sep 05, 2017 at 12:50:35AM +0300, Koos Zevenhoven < > k7ho...@gmail.com> wrote: > > cvar = contextvars.Var(default="the default value", > >description="example context variable") > >Why ``de

Re: [Python-ideas] PEP draft: context variables

2017-09-05 Thread Pavol Lisy
On 9/4/17, Koos Zevenhoven wrote: > Core concept > > > A context-local variable is represented by a single instance of > ``contextvars.Var``, say ``cvar``. Any code that has access to the ``cvar`` > object can ask for its value with respect to the current context. In the > high-level