Re: [Python-Dev] PEP 567 v2

2017-12-28 Thread Victor Stinner
Hi, I like the new version of the PEP using "read only mapping" and copy_context(). It's easier to understand. I'm ok with seeing a context as a mapping, but I am confused about a context variable considered as a mapping item. I still see a context variable as a variable, so something which has a

Re: [Python-Dev] PEP 567 v2

2017-12-28 Thread Nathaniel Smith
On Thu, Dec 28, 2017 at 1:51 AM, Victor Stinner wrote: > var = ContextVar('var', default=42) > > and: > > var = ContextVar('var') > var.set (42) > > behaves the same, no? No, they're different. The second sets the value in the current context. The first sets the value in all contexts that current

Re: [Python-Dev] PEP 567 v2

2017-12-28 Thread Chris Jerdonek
I have a couple basic questions around how this API could be used in practice. Both of my questions are for the Python API as applied to Tasks in asyncio. 1) Would this API support looking up the value of a context variable for **another** Task? For example, if you're managing multiple tasks using

[Python-Dev] 'continue'/'break'/'return' inside 'finally' clause

2017-12-28 Thread Serhiy Storchaka
Currently 'continue' is prohibited inside 'finally' clause, but 'break' and 'return' are allowed. What is the r 'continue' was prohibited in https://bugs.python.org/issue1542451. Should we prohibit also 'break' and 'return' or allow 'continue'? 'break' and 'return' are never used inside 'finall

Re: [Python-Dev] Heap allocate type structs in native extension modules?

2017-12-28 Thread Erik Bray
On Tue, Dec 26, 2017 at 3:00 PM, Benjamin Peterson wrote: > I imagine Cython already takes care of this? This appears to have a distinct purpose, albeit not unrelated to Cython. The OP's program would generate boilerplate C code for extension types the rest of which would perhaps be implemented

Re: [Python-Dev] 'continue'/'break'/'return' inside 'finally' clause

2017-12-28 Thread Guido van Rossum
Looks to me the prohibition was to prevent a crash. It makes more sense to fix it. On Dec 28, 2017 03:39, "Serhiy Storchaka" wrote: Currently 'continue' is prohibited inside 'finally' clause, but 'break' and 'return' are allowed. What is the r 'continue' was prohibited in https://bugs.python.or

Re: [Python-Dev] Documenting types outside of typing

2017-12-28 Thread Barry Warsaw
On Dec 27, 2017, at 18:59, Ivan Levkivskyi wrote: > > FWIW the same problem was discussed a year ago when documenting typing. At > that time the discussion was not conclusive, > so that some types use class:: directive while other use data:: directive. At > that time Guido was in favour of data

Re: [Python-Dev] PEP 567 v2

2017-12-28 Thread Yury Selivanov
On Thu, Dec 28, 2017 at 5:28 AM, Chris Jerdonek wrote: > I have a couple basic questions around how this API could be used in > practice. Both of my questions are for the Python API as applied to Tasks in > asyncio. > > 1) Would this API support looking up the value of a context variable for > **a

Re: [Python-Dev] PEP 567 v2

2017-12-28 Thread Yury Selivanov
On Thu, Dec 28, 2017 at 4:51 AM, Victor Stinner wrote: > Hi, > > I like the new version of the PEP using "read only mapping" and > copy_context(). It's easier to understand. Thanks, Victor! > > I'm ok with seeing a context as a mapping, but I am confused about a context > variable considered as

Re: [Python-Dev] PEP 567 v2

2017-12-28 Thread Guido van Rossum
Keep MISSING. On Dec 28, 2017 8:44 AM, "Yury Selivanov" wrote: > On Thu, Dec 28, 2017 at 4:51 AM, Victor Stinner > wrote: > > Hi, > > > > I like the new version of the PEP using "read only mapping" and > > copy_context(). It's easier to understand. > > Thanks, Victor! > > > > > I'm ok with seei

Re: [Python-Dev] 'continue'/'break'/'return' inside 'finally' clause

2017-12-28 Thread Serhiy Storchaka
28.12.17 16:38, Guido van Rossum пише: Looks to me the prohibition was to prevent a crash. It makes more sense to fix it. The crash can be fixed by just removing the check after finishing issue17611. But is there any use case for 'continue'/'break'/'return' inside 'finally' clause? The code

Re: [Python-Dev] 'continue'/'break'/'return' inside 'finally' clause

2017-12-28 Thread Guido van Rossum
I don't think the language definition should be judgmental here. The semantics are unambiguous. On Dec 28, 2017 11:38 AM, "Serhiy Storchaka" wrote: > 28.12.17 16:38, Guido van Rossum пише: > >> Looks to me the prohibition was to prevent a crash. It makes more sense >> to fix it. >> > > The crash

Re: [Python-Dev] PEP 567 v2

2017-12-28 Thread Victor Stinner
NLe 28 déc. 2017 11:20 AM, "Nathaniel Smith" a écrit : On Thu, Dec 28, 2017 at 1:51 AM, Victor Stinner wrote: > var = ContextVar('var', default=42) > > and: > > var = ContextVar('var') > var.set (42) > > behaves the same, no? No, they're different. The second sets the value in the current conte

Re: [Python-Dev] Is static typing still optional?

2017-12-28 Thread Brett Cannon
On Tue, 26 Dec 2017 at 21:00 Ned Batchelder wrote: > On 12/26/17 1:49 PM, Chris Barker wrote: > > On Sat, Dec 23, 2017 at 5:54 PM, Nick Coghlan wrote: > >> >> I still wonder about the "fields *must* be annotated" constraint though. >> I can understand a constraint that the style be *consistent*

Re: [Python-Dev] Heap allocate type structs in native extension modules?

2017-12-28 Thread Benjamin Peterson
On Thu, Dec 28, 2017, at 03:29, Erik Bray wrote: > On Tue, Dec 26, 2017 at 3:00 PM, Benjamin Peterson > wrote: > > I imagine Cython already takes care of this? > > This appears to have a distinct purpose, albeit not unrelated to > Cython. The OP's program would generate boilerplate C code for