Re: [Python-Dev] PEP 567 v3

2018-01-21 Thread Koos Zevenhoven
On Thu, Jan 18, 2018 at 3:53 AM, Yury Selivanov wrote: ​[] > > Given the time frame of the Python 3.7 release schedule it was decided > to defer this proposal to Python 3.8. > ​It occurs to me that I had misread this to refer to the whole PEP. Although I thought

Re: [Python-Dev] PEP 567 v3

2018-01-18 Thread Nathaniel Smith
On Thu, Jan 18, 2018 at 12:03 AM, Antoine Pitrou wrote: > On Wed, 17 Jan 2018 20:53:42 -0500 > Yury Selivanov wrote: >> >> Proposed by Antoine Pitrou, this could enable transparent >> cross-process use of ``Context`` objects, so the >> `Offloading

Re: [Python-Dev] PEP 567 v3

2018-01-18 Thread Antoine Pitrou
On Wed, 17 Jan 2018 20:53:42 -0500 Yury Selivanov wrote: > > Proposed by Antoine Pitrou, this could enable transparent > cross-process use of ``Context`` objects, so the > `Offloading execution to other threads`_ example would work with > a ``ProcessPoolExecutor`` too. >

Re: [Python-Dev] PEP 567 v3

2018-01-17 Thread Yury Selivanov
On Wed, Jan 17, 2018 at 8:53 PM, Yury Selivanov wrote: > On Wed, Jan 17, 2018 at 2:24 PM, Guido van Rossum > wrote: >> Perhaps you can update the PEP with a summary of the rejected ideas from >> this thread? > > The Rejected Ideas section of the

Re: [Python-Dev] PEP 567 v3

2018-01-17 Thread Yury Selivanov
On Wed, Jan 17, 2018 at 2:24 PM, Guido van Rossum wrote: > Perhaps you can update the PEP with a summary of the rejected ideas from > this thread? The Rejected Ideas section of the PEP is now updated with the below: Token.reset() instead of ContextVar.reset()

Re: [Python-Dev] PEP 567 v3

2018-01-17 Thread Victor Stinner
FYI In the PEP 540, I didn't try to elaborate on each design change, but I wrote a very short version history at the end: https://www.python.org/dev/peps/pep-0540/#version-history Maybe something like that would help for the PEP 567? Victor Le 17 janv. 2018 8:26 PM, "Guido van Rossum"

Re: [Python-Dev] PEP 567 v3

2018-01-17 Thread Guido van Rossum
Perhaps you can update the PEP with a summary of the rejected ideas from this thread? On Jan 17, 2018 7:23 AM, "Yury Selivanov" wrote: > On Wed, Jan 17, 2018 at 6:03 AM, Antoine Pitrou > wrote: > > On Tue, 16 Jan 2018 17:18:06 -0800 > > Nathaniel

Re: [Python-Dev] PEP 567 v3

2018-01-17 Thread Yury Selivanov
On Wed, Jan 17, 2018 at 6:03 AM, Antoine Pitrou wrote: > On Tue, 16 Jan 2018 17:18:06 -0800 > Nathaniel Smith wrote: >> On Tue, Jan 16, 2018 at 5:06 PM, Yury Selivanov >> wrote: >> > >> > I think it would be a very fragile thing In

Re: [Python-Dev] PEP 567 v3

2018-01-17 Thread Antoine Pitrou
On Tue, 16 Jan 2018 17:18:06 -0800 Nathaniel Smith wrote: > On Tue, Jan 16, 2018 at 5:06 PM, Yury Selivanov > wrote: > > > > I think it would be a very fragile thing In practice: if you have even > > one variable in the context that isn't pickleable,

Re: [Python-Dev] PEP 567 v3

2018-01-16 Thread Nick Coghlan
On 17 January 2018 at 11:27, Nathaniel Smith wrote: > On Tue, Jan 16, 2018 at 2:44 PM, Yury Selivanov > wrote: >> 4. ContextVar.reset(token) now raises a ValueError if the token was >> created in a different Context. > > A minor bit of polish: given that

Re: [Python-Dev] PEP 567 v3

2018-01-16 Thread Guido van Rossum
On Tue, Jan 16, 2018 at 5:33 PM, Yury Selivanov wrote: > On Tue, Jan 16, 2018 at 8:27 PM, Nathaniel Smith wrote: > [..] > > token = cvar.set(...) > > token.reset() > > I see the point, but I think that having the 'reset' method defined on > the

Re: [Python-Dev] PEP 567 v3

2018-01-16 Thread Yury Selivanov
On Tue, Jan 16, 2018 at 8:27 PM, Nathaniel Smith wrote: [..] > token = cvar.set(...) > token.reset() I see the point, but I think that having the 'reset' method defined on the ContextVar class is easier to grasp. It also feels natural that a pair of set/reset methods is defined

Re: [Python-Dev] PEP 567 v3

2018-01-16 Thread Nathaniel Smith
On Tue, Jan 16, 2018 at 2:44 PM, Yury Selivanov wrote: > 4. ContextVar.reset(token) now raises a ValueError if the token was > created in a different Context. A minor bit of polish: given that Token objects have to track the associated ContextVar anyway, I think it'd be

Re: [Python-Dev] PEP 567 v3

2018-01-16 Thread Nathaniel Smith
On Tue, Jan 16, 2018 at 5:06 PM, Yury Selivanov wrote: > On Tue, Jan 16, 2018 at 7:45 PM, Guido van Rossum wrote: >> On Tue, Jan 16, 2018 at 4:37 PM, Antoine Pitrou wrote: >>> >>> On Tue, 16 Jan 2018 17:44:14 -0500 >>> Yury

Re: [Python-Dev] PEP 567 v3

2018-01-16 Thread Yury Selivanov
On Tue, Jan 16, 2018 at 7:45 PM, Guido van Rossum wrote: > On Tue, Jan 16, 2018 at 4:37 PM, Antoine Pitrou wrote: >> >> On Tue, 16 Jan 2018 17:44:14 -0500 >> Yury Selivanov wrote: >> >> > Offloading execution to other threads >> >

Re: [Python-Dev] PEP 567 v3

2018-01-16 Thread Yury Selivanov
Thanks, Victor! ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Re: [Python-Dev] PEP 567 v3

2018-01-16 Thread Yury Selivanov
On Tue, Jan 16, 2018 at 6:53 PM, Guido van Rossum wrote: > On Tue, Jan 16, 2018 at 3:26 PM, Victor Stinner [..] >> I don't think that it's worth it to prevent misuage of reset(). IMHO >> it's fine if calling reset() twice reverts the variable state

Re: [Python-Dev] PEP 567 v3

2018-01-16 Thread Guido van Rossum
On Tue, Jan 16, 2018 at 4:37 PM, Antoine Pitrou wrote: > On Tue, 16 Jan 2018 17:44:14 -0500 > Yury Selivanov wrote: > > > Offloading execution to other threads > > - > > > > It is possible to run code in a

Re: [Python-Dev] PEP 567 v3

2018-01-16 Thread Antoine Pitrou
On Tue, 16 Jan 2018 17:44:14 -0500 Yury Selivanov wrote: > Offloading execution to other threads > - > > It is possible to run code in a separate OS thread using a copy > of the current thread context:: > > executor =

Re: [Python-Dev] PEP 567 v3

2018-01-16 Thread Guido van Rossum
On Tue, Jan 16, 2018 at 3:26 PM, Victor Stinner wrote: > Thanks for the updated PEP v3, it's now much better than PEP v2! > > I have no more complain against your PEP. I vote +1 for PEP 567 > contextvars! > Yeah! > The only open question I personally have is whether

Re: [Python-Dev] PEP 567 v3

2018-01-16 Thread Victor Stinner
Hi Yury, Thanks for the updated PEP v3, it's now much better than PEP v2! I have no more complain against your PEP. I vote +1 for PEP 567 contextvars! > The only open question I personally have is whether ContextVar.reset() > should be idempotent or not. Maybe we should be strict and raise an

[Python-Dev] PEP 567 v3

2018-01-16 Thread Yury Selivanov
Hi, This is a third version of PEP 567. Changes from v2: 1. PyThreadState now references Context objects directly (instead of referencing _ContextData). This fixes out of sync Context.get() and ContextVar.get(). 2. Added a new Context.copy() method. 3. Renamed Token.old_val property to