Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Greg Ewing
PJ Eby wrote: I find this a little weird. Why not just have `with` and `for` inside a coroutine dynamically check the iterator or context manager, and either behave sync or async accordingly? Why must there be a *syntactic* difference? It depends on whether you think it's important to have a

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Greg Ewing
Yury Selivanov wrote: I think there is another way... instead of pushing GET_ITER ... YIELD_FROM opcodes, we'll need to replace GET_ITER with another one: GET_ITER_SPECIAL ... YIELD_FROM I'm lost. What Python code are you suggesting this would be generated from? -- Greg

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Greg
On 23/04/2015 6:32 a.m., Andrew Svetlov wrote: If we forbid to call `async def` from regualr code how asyncio should work? I'd like to push `async def` everywhere in asyncio API where asyncio.coroutine required. As I suggested earlier, a way could be provided to mark a function as callable usin

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Greg Ewing
On 04/23/2015 04:18 AM, Yury Selivanov wrote: 2. We'll hack Gen(/ceval.c?) objects to raise an error if they are called directly and have a 'CO_COROUTINE' flag. By "Gen", do you mean the generator-function or the generator-iterator? That flag has to be on the generator-function, not the gener

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Andrew Svetlov
I guess to raise exception on unwinded async generator in destructor even in non-debug mode. Debug mode may have more complex info with source_traceback included, as Victor Stinner does for CoroWrapper. On Thu, Apr 23, 2015 at 4:27 AM, Yury Selivanov wrote: > Greg, > > On 2015-04-22 7:47 PM, Gre

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Yury Selivanov
Greg, On 2015-04-22 7:47 PM, Greg Ewing wrote: Yury Selivanov wrote: On the other hand, I hate the idea of grammatically requiring parentheses for 'await' expressions. That feels non-pytonic to me. How is it any different from grammatically requiring parens in an ordinary function call? Nob

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Andrew Svetlov
On Thu, Apr 23, 2015 at 3:35 AM, Guido van Rossum wrote: > On Wed, Apr 22, 2015 at 5:12 PM, Greg Ewing > wrote: >> >> Guido van Rossum wrote: >>> >>> On Wed, Apr 22, > OTOH I'm still struggling with what you have to do to >>> wrap a coroutine in a Task, the way its done in asyncio by the Task() >

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Yury Selivanov
On 2015-04-22 9:04 PM, Guido van Rossum wrote: On Wed, Apr 22, 2015 at 5:55 PM, Yury Selivanov wrote: On 2015-04-22 8:35 PM, Guido van Rossum wrote: On Wed, Apr 22, 2015 at 5:12 PM, Greg Ewing wrote: Guido van Rossum wrote: On Wed, Apr 22, > OTOH I'm still struggling with what you h

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Guido van Rossum
On Wed, Apr 22, 2015 at 5:55 PM, Yury Selivanov wrote: > On 2015-04-22 8:35 PM, Guido van Rossum wrote: > >> On Wed, Apr 22, 2015 at 5:12 PM, Greg Ewing >> wrote: >> >> Guido van Rossum wrote: >>> >>> On Wed, Apr 22, > OTOH I'm still struggling with what you have to do to wrap a coroutine

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Yury Selivanov
On 2015-04-22 8:35 PM, Guido van Rossum wrote: On Wed, Apr 22, 2015 at 5:12 PM, Greg Ewing wrote: Guido van Rossum wrote: On Wed, Apr 22, > OTOH I'm still struggling with what you have to do to wrap a coroutine in a Task, the way its done in asyncio by the Task() constructor, the loop.create

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-22 Thread Guido van Rossum
On Wed, Apr 22, 2015 at 2:38 PM, Chris Barker wrote: > > > Oh wait, maybe it won't -- a string IS a sequence of strings. That's why >> this is an insidious bug in the first place. > > On Tue, Apr 21, 2015 at 11:32 PM, Terry Reedy wrote: > > >> I was just thinking today that for this, typing need

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Guido van Rossum
On Wed, Apr 22, 2015 at 5:12 PM, Greg Ewing wrote: > Guido van Rossum wrote: > >> On Wed, Apr 22, > OTOH I'm still struggling with what you have to do to >> wrap a coroutine in a Task, the way its done in asyncio by the Task() >> constructor, the loop.create_task() method, and the async() functio

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-22 Thread Chris Barker
> Oh wait, maybe it won't -- a string IS a sequence of strings. That's why > this is an insidious bug in the first place. On Tue, Apr 21, 2015 at 11:32 PM, Terry Reedy wrote: > I was just thinking today that for this, typing needs a subtraction > (difference) operation in addition to an additio

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Greg Ewing
Guido van Rossum wrote: On Wed, Apr 22, > OTOH I'm still struggling with what you have to do to wrap a coroutine in a Task, the way its done in asyncio by the Task() constructor, the loop.create_task() method, and the async() function That's easy. You can always use costart() to adapt a cofunc

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Greg Ewing
Yury Selivanov wrote: On the other hand, I hate the idea of grammatically requiring parentheses for 'await' expressions. That feels non-pytonic to me. How is it any different from grammatically requiring parens in an ordinary function call? Nobody ever complained about that. In the PEP 3152

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Paul Sokolovsky
Hello, On Wed, 22 Apr 2015 09:53:39 -0700 Rajiv Kumar wrote: > I'd like to suggest another way around some of the issues here, with > apologies if this has already been discussed sometime in the past. > > From the viewpoint of a Python programmer, there are two distinct > reasons for wanting to

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Paul Sokolovsky
Hello, On Wed, 22 Apr 2015 13:31:18 -0700 Guido van Rossum wrote: > On Wed, Apr 22, 2015 at 1:10 PM, Andrew Svetlov > wrote: > > > On Wed, Apr 22, 2015 at 10:44 PM, PJ Eby > > wrote: > > > On Tue, Apr 21, 2015 at 1:26 PM, Yury Selivanov > > > > > wrote: > > >> It is an error to pass a regula

Re: [Python-Dev] Committing into which branches?

2015-04-22 Thread Łukasz Langa
> On Apr 22, 2015, at 2:45 PM, Facundo Batista wrote: > > Hola! > > I just commited a simple improvement to HTTPError repr, and checking > in the source code page [0], I see that my commit has a small > "default" besides it; and other commits don't have that, but have 2.7, > or 3.4, etc... > >

Re: [Python-Dev] Committing into which branches?

2015-04-22 Thread Brett Cannon
The default branch is going to become 3.5, so you're fine. On Wed, Apr 22, 2015 at 5:45 PM Facundo Batista wrote: > Hola! > > I just commited a simple improvement to HTTPError repr, and checking > in the source code page [0], I see that my commit has a small > "default" besides it; and other com

Re: [Python-Dev] Committing into which branches?

2015-04-22 Thread Facundo Batista
On Wed, Apr 22, 2015 at 6:46 PM, Brett Cannon wrote: > The default branch is going to become 3.5, so you're fine. Thanks!! -- .Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ Twitter: @facundobatista ___ Python-D

[Python-Dev] Committing into which branches?

2015-04-22 Thread Facundo Batista
Hola! I just commited a simple improvement to HTTPError repr, and checking in the source code page [0], I see that my commit has a small "default" besides it; and other commits don't have that, but have 2.7, or 3.4, etc... So, question: Did I commit in the correct branch? Should I have done anyth

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Yury Selivanov
Ludovic, On 2015-04-22 5:00 PM, Ludovic Gasc wrote: Not related, but one of my coworkers asked me if with the new syntax it will be possible to write an async decorator for coroutines. If I understand correctly new grammar in PEP, it seems to be yes, but could you confirm ? There shouldn't be

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Ludovic Gasc
2015-04-22 22:46 GMT+02:00 Victor Stinner : > > Kind (A): > > - "yield-from coroutines" or "coroutines based on yield-from" > - maybe "asyncio coroutines" > - "legacy coroutines"? > "legacy coroutines" name has the advantage to be directly clear it isn't a good idea to write new source code with t

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Victor Stinner
Greg Ewing canterbury.ac.nz> writes: > I still don't like the idea of hijacking the generic > term "coroutine" and using it to mean this particular > type of object. There are only two hard things in Computer Science: cache invalidation and naming things. -- Phil Karlton :-) When revie

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Guido van Rossum
On Wed, Apr 22, 2015 at 1:10 PM, Andrew Svetlov wrote: > On Wed, Apr 22, 2015 at 10:44 PM, PJ Eby wrote: > > On Tue, Apr 21, 2015 at 1:26 PM, Yury Selivanov > wrote: > >> It is an error to pass a regular context manager without ``__aenter__`` > >> and ``__aexit__`` methods to ``async with``. I

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Victor Stinner
Hi, Guido van Rossum python.org> writes: > I'm slowly warming up to Greg's notion that you can't call a coroutine (or whatever it's called) without a special keyword. A huge part of the asyncio module is based on "yield from fut" where fut is a Future object. How do you write this using the PEP

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Yury Selivanov
Hi PJ, On 2015-04-22 3:44 PM, PJ Eby wrote: On Tue, Apr 21, 2015 at 1:26 PM, Yury Selivanov wrote: It is an error to pass a regular context manager without ``__aenter__`` and ``__aexit__`` methods to ``async with``. It is a ``SyntaxError`` to use ``async with`` outside of a coroutine. I find

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Ludovic Gasc
+1 about Andrew Svetlov proposition: please help to migrate as smoothly as possible to async/await. -- Ludovic Gasc (GMLudo) http://www.gmludo.eu/ 2015-04-22 20:32 GMT+02:00 Andrew Svetlov : > For now I can use mix asyncio.coroutines and `async def` functions, I > mean I can write `await f()` in

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Ethan Furman
On 04/22, PJ Eby wrote: > tl;dr: I like the overall ideas but hate the syntax and type > segregation involved: declaring a function async at the top is OK to > enable async with/for semantics and await expressions, but the rest > seems unnecessary and bad for writing robust code. (e.g. note that

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Andrew Svetlov
On Wed, Apr 22, 2015 at 10:44 PM, PJ Eby wrote: > On Tue, Apr 21, 2015 at 1:26 PM, Yury Selivanov > wrote: >> It is an error to pass a regular context manager without ``__aenter__`` >> and ``__aexit__`` methods to ``async with``. It is a ``SyntaxError`` >> to use ``async with`` outside of a cor

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread PJ Eby
On Tue, Apr 21, 2015 at 1:26 PM, Yury Selivanov wrote: > It is an error to pass a regular context manager without ``__aenter__`` > and ``__aexit__`` methods to ``async with``. It is a ``SyntaxError`` > to use ``async with`` outside of a coroutine. I find this a little weird. Why not just have `

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Andrew Svetlov
On Wed, Apr 22, 2015 at 10:24 PM, Yury Selivanov wrote: > > > On 2015-04-22 2:53 PM, Andrew Svetlov wrote: >> >> On Wed, Apr 22, 2015 at 9:45 PM, Yury Selivanov >> wrote: > > [...] >>> >>> If we forbid to call `async def` from regualr code how asyncio should work? I'd like to push `asyn

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Yury Selivanov
On 2015-04-22 2:53 PM, Andrew Svetlov wrote: On Wed, Apr 22, 2015 at 9:45 PM, Yury Selivanov wrote: [...] If we forbid to call `async def` from regualr code how asyncio should work? I'd like to push `async def` everywhere in asyncio API where asyncio.coroutine required. You'll have to us

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Andrew Svetlov
On Wed, Apr 22, 2015 at 9:45 PM, Yury Selivanov wrote: > Andrew, > > On 2015-04-22 2:32 PM, Andrew Svetlov wrote: >> >> For now I can use mix asyncio.coroutines and `async def` functions, I >> mean I can write `await f()` inside async def to call >> asyncio.coroutine `f` and vise versa: I can use

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Yury Selivanov
Andrew, On 2015-04-22 2:32 PM, Andrew Svetlov wrote: For now I can use mix asyncio.coroutines and `async def` functions, I mean I can write `await f()` inside async def to call asyncio.coroutine `f` and vise versa: I can use `yield from g()` inside asyncio.coroutine to call `async def g(): ...`.

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Andrew Svetlov
For now I can use mix asyncio.coroutines and `async def` functions, I mean I can write `await f()` inside async def to call asyncio.coroutine `f` and vise versa: I can use `yield from g()` inside asyncio.coroutine to call `async def g(): ...`. If we forbid to call `async def` from regualr code how

Re: [Python-Dev] typeshed for 3rd party packages

2015-04-22 Thread Guido van Rossum
On Wed, Apr 22, 2015 at 9:26 AM, Ian Cordasco wrote: > As the other maintainer of requests, I think having hints *might* help > some developers, but looking at what Cory generated (which looks to be > valid), I'm wondering about something else with Type Hints. > > I've heard several people say "J

Re: [Python-Dev] typeshed for 3rd party packages

2015-04-22 Thread Guido van Rossum
On Wed, Apr 22, 2015 at 9:12 AM, Skip Montanaro wrote: > > On Wed, Apr 22, 2015 at 10:43 AM, Guido van Rossum > wrote: > >> For Requests, it looks like it may be better not to have stubs at all. > > > Can you expand on this? Why would Requests be any different than any other > module/package? >

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Yury Selivanov
Hi Rajiv, On 2015-04-22 12:53 PM, Rajiv Kumar wrote: I'd like to suggest another way around some of the issues here, with apologies if this has already been discussed sometime in the past. From the viewpoint of a Python programmer, there are two distinct reasons for wanting to suspend executio

Re: [Python-Dev] [python-committers] [RELEASED] Python 3.5.0a4 is now available

2015-04-22 Thread Steve Dower
Whoops, sorry. Yeah, I knew about that behavior, but in hindsight it's obviously going to be a surprise for others :) One plain zip file coming up for the next release. All the binaries will be signed and paranoid people can check the GPG sig and embed their own hashes if not the files themselv

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Rajiv Kumar
I'd like to suggest another way around some of the issues here, with apologies if this has already been discussed sometime in the past. >From the viewpoint of a Python programmer, there are two distinct reasons for wanting to suspend execution in a block of code: 1. To yield a value from an itera

Re: [Python-Dev] typeshed for 3rd party packages

2015-04-22 Thread Ian Cordasco
On Wed, Apr 22, 2015 at 11:30 AM, Skip Montanaro wrote: > > > On Wed, Apr 22, 2015 at 11:26 AM, Ian Cordasco > wrote: > >> On a separate thread Cory provided an example of what the hints would >> look like for *part* of one function in the requests public functional API. >> > > Thanks. That enco

Re: [Python-Dev] typeshed for 3rd party packages

2015-04-22 Thread Ian Cordasco
On Wed, Apr 22, 2015 at 11:12 AM, Skip Montanaro wrote: > > On Wed, Apr 22, 2015 at 10:43 AM, Guido van Rossum > wrote: > >> For Requests, it looks like it may be better not to have stubs at all. > > > Can you expand on this? Why would Requests be any different than any other > module/package? >

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Yury Selivanov
Hi Guido, On 2015-04-22 11:50 AM, Guido van Rossum wrote: On Wed, Apr 22, 2015 at 8:40 AM, Yury Selivanov wrote: On the one hand I like your idea to disallow calling coroutines without a special keyword (await in case of PEP 492). It has downsides, but there is some elegance in it. On the ot

Re: [Python-Dev] typeshed for 3rd party packages

2015-04-22 Thread Skip Montanaro
On Wed, Apr 22, 2015 at 10:43 AM, Guido van Rossum wrote: > For Requests, it looks like it may be better not to have stubs at all. Can you expand on this? Why would Requests be any different than any other module/package? As for versioning, I think stub files would absolutely have to declare t

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Guido van Rossum
On Wed, Apr 22, 2015 at 8:40 AM, Yury Selivanov wrote: > > On the one hand I like your idea to disallow calling > coroutines without a special keyword (await in case of > PEP 492). It has downsides, but there is some > elegance in it. On the other hand, I hate the idea > of grammatically requiri

Re: [Python-Dev] typeshed for 3rd party packages

2015-04-22 Thread Guido van Rossum
I definitely think that we shouldn't jump the gun here and tread carefully. Both Marc-André and Cory brought up good things to watch out for. For closed-source software the only way to obtain stubs is presumably from the author, if they care. As Gregory Smith said in another thread, the tooling wi

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Yury Selivanov
Hi Greg, On 2015-04-22 2:05 AM, Greg Ewing wrote: Yury Selivanov wrote: 1. CO_ASYNC flag was renamed to CO_COROUTINE; 2. sys.set_async_wrapper() was renamed to sys.set_coroutine_wrapper(); 3. New function: sys.get_coroutine_wrapper(); 4. types.async_def() renamed to types.coroutine(); I

Re: [Python-Dev] [python-committers] [RELEASED] Python 3.5.0a4 is now available

2015-04-22 Thread Paul Moore
On 22 April 2015 at 13:45, Paul Moore wrote: > On 21 April 2015 at 23:05, Steve Dower wrote: >> I made it a self-extracting RAR file so it could be signed, but I've already >> had multiple people query it so the next release will probably just be a >> plain ZIP file. I just need to figure out s

Re: [Python-Dev] [python-committers] [RELEASED] Python 3.5.0a4 is now available

2015-04-22 Thread Paul Moore
On 21 April 2015 at 23:05, Steve Dower wrote: > I made it a self-extracting RAR file so it could be signed, but I've already > had multiple people query it so the next release will probably just be a > plain ZIP file. I just need to figure out some reliable way of validating the > download othe

Re: [Python-Dev] typeshed for 3rd party packages

2015-04-22 Thread Cory Benfield
On 22 April 2015 at 11:46, M.-A. Lemburg wrote: > Unlike with translations, where missing or poor ones don't have > much effect on the usefulness of the software, a type checker > would complain loudly and probably show lots of false positives > (if you read a type bug as "positive"), causing the

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-22 Thread Cory Benfield
On 21 April 2015 at 17:59, Guido van Rossum wrote: > For me, PEP 484 is a stepping stone. Among the authors of PEP 484 there was > much discussion about duck typing, and mypy even has some limited support > for duck typing (I think you can still find it by searching the mypy code > for "protocol")

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-22 Thread Cory Benfield
On 21 April 2015 at 18:12, Steven D'Aprano wrote: > I expect that dealing with duck typing will be very high on the list > of priorities for the future. In the meantime, for this specific use-case, > you're probably not going to be able to statically check this type hint. > Your choices would be:

Re: [Python-Dev] typeshed for 3rd party packages

2015-04-22 Thread M.-A. Lemburg
On 21.04.2015 18:08, Guido van Rossum wrote: > On Tue, Apr 21, 2015 at 12:33 AM, M.-A. Lemburg wrote: > >> On 21.04.2015 05:37, Guido van Rossum wrote: >>> On Mon, Apr 20, 2015 at 4:41 PM, Jack Diederich >> wrote: * Uploading stubs for other people's code is a terrible idea. Who do I c