-
-
Notifications
You must be signed in to change notification settings - Fork 184
Add new loop.create_future() method. #290
Conversation
|
We don't want this committed before |
|
No, let's hold off on this one for a little bit. |
|
@1st1: Python 3.5.1 has been out for a while now. You can safely merge this! |
|
Hi Guido! Sorry for the delayed reply, I was away from the office. Before merging this PR, I'd like to reiterate on a few things:
With all that in mind, are you still OK with merging this PR? |
|
I forgot -- do you want this PR in 3.5.2 or the C-accelerated Future class? Why wouldn't uvloop's Future class be able to inherit from the default Future class (accelerated or not)? For most people leaving out the loop= parameter doesn't matter because there's only one loop they care about (or at least they're doing the Future instantiation when the right loop is current -- either way it doesn't matter). I've noticed that create_task() has caused some confusion (see the recent issue #306 demanding that certain functions that currently return a Future be changed to be actual coroutines so they could be passed to create_task()). I worry that create_future() will cause more confusion (as yet unknown -- I hadn't anticipated the create_task() confusion either). Anyway, do you really need this? |
The latter. If we have a fast Future implementation, we don't need We might need Another interesting benefit of
If you don't see enough benefits in having [1] and [2], then I propose to close this PR and focus on adding a C implementation of Future in CPython.
Oh, that's no good :( TBH, I always worried that we treat Futures and coroutines as they are interchangeable (in docs). Futures have |
|
On Fri, Jan 8, 2016 at 1:06 PM, Yury Selivanov [email protected]
So I don't believe this helps.
--Guido van Rossum (python.org/~guido) |
|
Hi Guido, I continue to experiment with uvloop and The streams echo server benchmark becomes 25% faster, if I replace Future is the only core primitive in asyncio that I can't improve in uvloop. Even for tasks we have a Could you please re-consider merging this PR? |
|
Did a quick futures benchmark here, the result is that uvloop's Futures are 1.8-2x faster. Benchmarks for sock_recv/sock_sendall are >70% faster. I also think that |
|
I am completely overwhelmed with stuff, can it wait a few days?
|
|
Absolutely. I only want this to make it to 3.5.2 if possible.
|
|
I don't think new APIs or new features are in scope of 3.5.2, my guess is this will have to wait for 3.6... |
|
Actually they are, asyncio is still provisional in 3.5.
|
Yes, pretty please... There are some significant performance improvements here. |
|
This PR is out of date, and I'm a little confused. But I think we should go ahead with something. Here are some questions and observations. This PR seems to do a few things:
So the last two bullets feel uncontroversial, but I'm curious about the addition of ABCMeta. (In mypy, we found that this significantly slows down some things.) Also, in some previous comment you seemed to be claiming that you didn't (or at least might not) need create_future() after all, and in some other comment you seemed to be indicating that you really want an accelerated Future implementation in CPython. So which is it? Can you lay everything clearly on the table please? (We could open a new issue or use the python-tulip list, but we might as well continue the discussion here, unless you think you'd like to start a fresh PR.) |
|
Thanks for reviewing!
Having an ABC for Futures was something I wanted to do in the beginning, but now we don't need that. I'll update the PR. And yes, adding an
Yes, I created an issue (http://bugs.python.org/issue26081) to re-implement the OTOH, I tried to re-implement I think that |
|
What if some library or app mixes calling create_future() and instantiating Also what about code that calls isinstance(x, Future)? On Sunday, May 15, 2016, Yury Selivanov [email protected] wrote:
--Guido (mobile) |
That's totally fine.
Here's some pseudocode illustrating how it's implemented in uvloop: cdef class BaseFuture:
"""Optimized & statically typed Future implementation"""
class Future(BaseFuture, asyncio.Future):
passBecause |
b651c4d to
d792479
Compare
|
Awesome. Let me know when the updated PR is ready!
(Also, super thanks for all the PR merging and other stuff you've done
recently to asyncio. As you might have guessed I'm totally consumed by
typing stuff and I rarely have time to dive deep enough into asyncio. So
you and Victor are basically it! Rest assured I am still watching the
stream of notifications and will jump in when I see anything fishy
happening. 3.5.2 will be a great release!)
|
It should be ready now. I can merge it myself if you don't have time.
NP! I can't wait to hear your typing talk on PyCon! And I have a few |
|
(I'm not sure why github shows that the branch is out of date -- I've just rebased it on top of the master branch. Anyways, we can merge manually) |
|
LGTM. Can you manually merge this? The GitHub warning feels scary, maybe it's because the branch is so old? Also you should probably make sure no new Future() calls have appeared since you wrote this. |
Yep, I did that ;) -- Indeed we had a new one, where we parse ip addresses. Thanks a lot, Guido, I'll merge it now. |
|
Merged. Thanks again! |
|
Good luck! Remember to update the docs.
|
This PR adds a new API --
loop.create_future()(see discussion in #282 for details).