Re: [Python-ideas] PEP 550 v2

2017-08-23 Thread Guido van Rossum
OK, I get it now. I really liked the analysis of existing uses in Django. So no worries about this. On Wed, Aug 23, 2017 at 5:36 PM, Yury Selivanov wrote: > There's another "major" problem with theading.local()-like API for PEP > 550: C API. > > threading.local() in C

Re: [Python-ideas] PEP 550 v2

2017-08-23 Thread Yury Selivanov
There's another "major" problem with theading.local()-like API for PEP 550: C API. threading.local() in C right now is PyThreadState_GetDict(), which returns a dictionary for the current thread, that can be queried/modified with PyDict_* functions. For PEP 550 this would not work. The advantage

Re: [Python-ideas] PEP 550 v2

2017-08-23 Thread Nathaniel Smith
On Wed, Aug 23, 2017 at 8:41 AM, Guido van Rossum wrote: > If we're extending the analogy with thread-locals we should at least > consider making each instantiation return a namespace rather than something > holding a single value. We have > > log_state = threading.local() >

Re: [Python-ideas] PEP 550 v2

2017-08-23 Thread Ethan Furman
On 08/23/2017 08:41 AM, Guido van Rossum wrote: If we're extending the analogy with thread-locals we should at least consider making each instantiation return a namespace rather than something holding a single value. +1 -- ~Ethan~ ___ Python-ideas

Re: [Python-ideas] PEP 550 v2

2017-08-23 Thread Guido van Rossum
On Wed, Aug 23, 2017 at 2:00 AM, Nick Coghlan wrote: > On 21 August 2017 at 07:01, Barry wrote: > > I'm not clear why there is a new_context_key which seems not to be a key. > > It seems that the object is a container for a single value. > > > >

Re: [Python-ideas] PEP 550 v2

2017-08-23 Thread Nick Coghlan
On 21 August 2017 at 07:01, Barry wrote: > I'm not clear why there is a new_context_key which seems not to be a key. > It seems that the object is a container for a single value. > > Key.set( value ) does not feel right. It's basically borrowed from procedural thread

Re: [Python-ideas] PEP 550 v2

2017-08-20 Thread Barry
I'm not clear why there is a new_context_key which seems not to be a key. It seems that the object is a container for a single value. Key.set( value ) does not feel right. Container.set( value ) is fine. Barry > On 16 Aug 2017, at 00:55, Yury Selivanov wrote: > >

Re: [Python-ideas] PEP 550 v2

2017-08-19 Thread Neil Girdhar
Cool to see this on python-ideas. I'm really looking forward to this PEP 550 or 521. On Wednesday, August 16, 2017 at 3:19:29 AM UTC-4, Nathaniel Smith wrote: > > On Tue, Aug 15, 2017 at 4:55 PM, Yury Selivanov > wrote: > > Hi, > > > > Here's the PEP 550 version 2. >

Re: [Python-ideas] PEP 550 v2

2017-08-19 Thread Nathaniel Smith
On Fri, Aug 18, 2017 at 6:25 PM, Ethan Furman wrote: > On 08/17/2017 02:40 AM, Nick Coghlan wrote: >> >> On 17 August 2017 at 04:38, Yury Selivanov wrote: > > >> ck.get_value() attempts to look up the value for that key in the >> currently active execution context. >>

Re: [Python-ideas] PEP 550 v2

2017-08-18 Thread Guido van Rossum
I'm also confused by these, because they share the noun part of their name, but their use and meaning is quite different. The PEP defines an EC as a stack of LCs, and (apart from strings :-) it's usually not a good idea to use the same term for a container and its items. On Fri, Aug 18, 2017 at

Re: [Python-ideas] PEP 550 v2

2017-08-18 Thread Ethan Furman
On 08/16/2017 08:43 AM, Yury Selivanov wrote: To be honest, I really like Execution Context and Local Context names. I'm curious if other people are confused with them. +1 confused :/ -- ~Ethan~ ___ Python-ideas mailing list

Re: [Python-ideas] PEP 550 v2

2017-08-18 Thread Ethan Furman
On 08/17/2017 02:40 AM, Nick Coghlan wrote: On 17 August 2017 at 04:38, Yury Selivanov wrote: ck.get_value() attempts to look up the value for that key in the currently active execution context. If it doesn't find one, it then tries each of the execution contexts in the currently

Re: [Python-ideas] PEP 550 v2

2017-08-18 Thread Yury Selivanov
On Fri, Aug 18, 2017 at 1:09 AM, Nick Coghlan wrote: > On 17 August 2017 at 01:22, Yury Selivanov wrote: >> On Wed, Aug 16, 2017 at 4:07 AM, Nick Coghlan wrote: Coroutine Object Modifications

Re: [Python-ideas] PEP 550 v2

2017-08-18 Thread Yury Selivanov
On Fri, Aug 18, 2017 at 2:12 AM, Stefan Behnel wrote: > Nathaniel Smith schrieb am 16.08.2017 um 09:18: >> On Tue, Aug 15, 2017 at 4:55 PM, Yury Selivanov wrote: >>> Here's the PEP 550 version 2. >> Awesome! > > +1 > >>> Backwards Compatibility >>> === >>>

Re: [Python-ideas] PEP 550 v2

2017-08-18 Thread Nick Coghlan
On 18 August 2017 at 16:12, Stefan Behnel wrote: > Nathaniel Smith schrieb am 16.08.2017 um 09:18: >> On Tue, Aug 15, 2017 at 4:55 PM, Yury Selivanov wrote: >>> Backwards Compatibility >>> === >>> >>> This proposal preserves 100% backwards compatibility.

Re: [Python-ideas] PEP 550 v2

2017-08-18 Thread Stefan Behnel
Nathaniel Smith schrieb am 16.08.2017 um 09:18: > On Tue, Aug 15, 2017 at 4:55 PM, Yury Selivanov wrote: >> Here's the PEP 550 version 2. > Awesome! +1 >> Backwards Compatibility >> === >> >> This proposal preserves 100% backwards compatibility. > > While this is mostly true

Re: [Python-ideas] PEP 550 v2

2017-08-17 Thread Nick Coghlan
On 17 August 2017 at 01:22, Yury Selivanov wrote: > On Wed, Aug 16, 2017 at 4:07 AM, Nick Coghlan wrote: >>> Coroutine Object Modifications >>> ^^ >>> >>> To achieve this, a small set of modifications to the coroutine

Re: [Python-ideas] PEP 550 v2

2017-08-17 Thread Nick Coghlan
On 17 August 2017 at 02:55, Yury Selivanov wrote: > And immediately after I hit "send" I realized that this is a bit more > complicated. > > In order for Tasks to remember the full execution context of where > they were created, we need a new method that would allow to

Re: [Python-ideas] PEP 550 v2

2017-08-17 Thread Nick Coghlan
On 17 August 2017 at 04:38, Yury Selivanov wrote: > On Wed, Aug 16, 2017 at 1:13 PM, Stefan Krah wrote: > While I'm trying to avoid using scoping terminology for PEP 550, there's > one parallel -- as with regular Python scoping you have global

Re: [Python-ideas] PEP 550 v2

2017-08-17 Thread Nick Coghlan
On 17 August 2017 at 02:36, Yury Selivanov wrote: > Yeah, this is tricky. The main issue is indeed the confusion of what > methods you need to call -- "get/set" or > "get_local_state/set_local_state". > > On some level the problem is very similar to regular Python scoping

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Yury Selivanov
On Wed, Aug 16, 2017 at 12:55 PM, Yury Selivanov [..] > And immediately after I hit "send" I realized that this is a bit more > complicated. > > In order for Tasks to remember the full execution context of where > they were created, we need a new method that would allow to run with > *both* exec

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Yury Selivanov
On Wed, Aug 16, 2017 at 4:12 PM, Antoine Pitrou wrote: > > > Hi, > >> * ``sys.get_execution_context()`` function. The function returns a >> copy of the current EC: an ``ExecutionContext`` instance. > > Can you explain the requirement for it being a copy? When the execution

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Stefan Krah
On Wed, Aug 16, 2017 at 12:40:26PM -0400, Yury Selivanov wrote: > On Wed, Aug 16, 2017 at 12:08 PM, Stefan Krah wrote: > > On Wed, Aug 16, 2017 at 11:00:43AM -0400, Yury Selivanov wrote: > >> "Context" is an established term for what PEP 550 tries to accomplish. > >> It's

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Yury Selivanov
On Wed, Aug 16, 2017 at 12:51 PM, Yury Selivanov wrote: > On Wed, Aug 16, 2017 at 5:36 AM, Nick Coghlan wrote: >> On 16 August 2017 at 17:18, Nathaniel Smith wrote: >> [Yury wrote] > [..] * If ``coro.cr_local_context`` is an

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Yury Selivanov
On Wed, Aug 16, 2017 at 5:36 AM, Nick Coghlan wrote: > On 16 August 2017 at 17:18, Nathaniel Smith wrote: > [Yury wrote] [..] >>> * If ``coro.cr_local_context`` is an empty ``LocalContext`` object >>> that ``coro`` was created with, the interpreter will

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Yury Selivanov
On Wed, Aug 16, 2017 at 12:08 PM, Stefan Krah wrote: > On Wed, Aug 16, 2017 at 11:00:43AM -0400, Yury Selivanov wrote: >> "Context" is an established term for what PEP 550 tries to accomplish. >> It's used in multiple languages and runtimes, and while researching >> this

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Yury Selivanov
On Wed, Aug 16, 2017 at 3:18 AM, Nathaniel Smith wrote: > On Tue, Aug 15, 2017 at 4:55 PM, Yury Selivanov > wrote: >> Hi, >> >> Here's the PEP 550 version 2. > > Awesome! Thanks! [..] >> >> * **Local Context**, or LC, is a key/value mapping that stores

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Stefan Krah
On Thu, Aug 17, 2017 at 01:03:21AM +1000, Nick Coghlan wrote: > For "ContextItem" for example, we may actually be better off calling > it "ContextKey", and have the methods be "ck.get_value()" and > "ck.set_value()". That would get us closer to the POSIX TSS > terminology, and emphasises that the

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Stefan Krah
On Wed, Aug 16, 2017 at 11:00:43AM -0400, Yury Selivanov wrote: > "Context" is an established term for what PEP 550 tries to accomplish. > It's used in multiple languages and runtimes, and while researching > this topic I didn't see anybody confused with the concept on > StackOverflow/etc. For me

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Yury Selivanov
On Wed, Aug 16, 2017 at 11:03 AM, Nick Coghlan wrote: > On 17 August 2017 at 00:25, Stefan Krah wrote: >> Perhaps it would be possible to name the data structures by their >> functionality. >> E.g. if ExecutionContext is a stack, use ExecutionStack? >>

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Yury Selivanov
On Wed, Aug 16, 2017 at 4:07 AM, Nick Coghlan wrote: > TLDR: I really like this version, and the tweaks I suggest below are > just cosmetic. Thanks, Nick! > I figure if there are any major technical traps > lurking, you'll find them as you work through updating the reference

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Nick Coghlan
On 17 August 2017 at 00:25, Stefan Krah wrote: > Perhaps it would be possible to name the data structures by their > functionality. > E.g. if ExecutionContext is a stack, use ExecutionStack? > > Or if the dynamic scope angle should be highlighted, perhaps ExecutionScope > or

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Yury Selivanov
On Wed, Aug 16, 2017 at 10:25 AM, Stefan Krah wrote: > On Wed, Aug 16, 2017 at 12:18:23AM -0700, Nathaniel Smith wrote: >> > Here's the PEP 550 version 2. >> >> Awesome! >> >> Some of the changes from v1 to v2 might be a bit confusing -- in >> particular the thing where

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Yury Selivanov
On Wed, Aug 16, 2017 at 2:53 AM, Jelle Zijlstra wrote: [..] >> >> The below is an example of how context items can be used:: >> >> my_context = sys.new_context_item(description='mylib.context') >> my_context.set('spam') > > > Minor suggestion: Could we allow

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Stefan Krah
On Wed, Aug 16, 2017 at 12:18:23AM -0700, Nathaniel Smith wrote: > > Here's the PEP 550 version 2. > > Awesome! > > Some of the changes from v1 to v2 might be a bit confusing -- in > particular the thing where ExecutionContext is now a stack of > LocalContext objects instead of just being a

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Nick Coghlan
On 16 August 2017 at 18:37, Nathaniel Smith wrote: > On Tue, Aug 15, 2017 at 11:53 PM, Jelle Zijlstra > wrote: >> Minor suggestion: Could we allow something like >> `sys.set_new_context_item(description='mylib.context', >> initial_value='spam')`? That

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Nick Coghlan
On 16 August 2017 at 17:18, Nathaniel Smith wrote: [Yury wrote] >> For these purposes we add a set of new APIs (they will be used in >> later sections of this specification): >> >> * ``sys.new_local_context()``: create an empty ``LocalContext`` >> object. >> >> *

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Jelle Zijlstra
2017-08-16 10:37 GMT+02:00 Nathaniel Smith : > On Tue, Aug 15, 2017 at 11:53 PM, Jelle Zijlstra > wrote: > > Minor suggestion: Could we allow something like > > `sys.set_new_context_item(description='mylib.context', > > initial_value='spam')`? That would

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Nathaniel Smith
On Tue, Aug 15, 2017 at 11:53 PM, Jelle Zijlstra wrote: > Minor suggestion: Could we allow something like > `sys.set_new_context_item(description='mylib.context', > initial_value='spam')`? That would make it easier for type checkers to infer > the type of a ContextItem,

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Nick Coghlan
TLDR: I really like this version, and the tweaks I suggest below are just cosmetic. I figure if there are any major technical traps lurking, you'll find them as you work through updating the reference implementation. On 16 August 2017 at 09:55, Yury Selivanov wrote: >

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Nathaniel Smith
On Tue, Aug 15, 2017 at 4:55 PM, Yury Selivanov wrote: > Hi, > > Here's the PEP 550 version 2. Awesome! Some of the changes from v1 to v2 might be a bit confusing -- in particular the thing where ExecutionContext is now a stack of LocalContext objects instead of just

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Jelle Zijlstra
2017-08-16 1:55 GMT+02:00 Yury Selivanov : > Hi, > > Here's the PEP 550 version 2. Thanks to a very active and insightful > discussion here on Python-ideas, we've discovered a number of > problems with the first version of the PEP. This version is a complete > rewrite

[Python-ideas] PEP 550 v2

2017-08-15 Thread Yury Selivanov
Hi, Here's the PEP 550 version 2. Thanks to a very active and insightful discussion here on Python-ideas, we've discovered a number of problems with the first version of the PEP. This version is a complete rewrite (only Abstract, Rationale, and Goals sections were not updated). The updated PEP