-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement asyncio.Task in C #72730
Comments
The attached patch implements asyncio.Task in C. Besides that, it also implements Argument Clinic for C Future. Performance improvement on a simple echo server implementation using asyncio.streams: Python Future & Task | C Future & Py Task | C Future & C Task Both Task and Future implemented in C, make asyncio programs up to 25-30% faster. The patch is 100% backwards compatible. I modified asyncio tests to cross test Tasks and Futures implementations, i.e. to run Task+Future, Task+CFuture, CTask+Future, CTask+CFuture tests. No refleaks or other bugs. All uvloop functional tests pass without any problem. Ned, Guido, are you OK if I merge this in 3.6 before beta 3? I'm confident that the patch is stable and even if something comes up we have time to fix it or even retract the patch. The performance boost is very impressive, and I can also make uvloop simpler. |
Also, with this patch uvloop becomes ~3-5% faster too. |
Wow! Great Job! (nit fix) Some modules doesn't sort imports in lexicography. |
Yes!
Thanks a lot! |
If it's OK with Guido, it's OK with me for 360b3. (That's Monday.) |
Very impressive. |
I don't want to be the decider here. I don't have time to review the |
I also trust Yury to do the right thing. |
Guido, Ned, thanks! Andrew already glanced through the code, let's see what Inada-san says. I'm uploading an updated patch addressing Andrew's review. |
Uploading a new patch: sorted imports; added a unittest that exceptions in loop.call_soon aren't breaking Task.__init__. |
Why isfuture() is moved, and asyncio.coroutine uses |
Import cycles:
Long story short, I don't see a way of keeping |
And tasks.py also imports coroutines.py (which was importing futures.py), making the cycle even worse. Anyways, I don't see a problem in moving a function or two that everybody uses into a separate module. |
New changeset db5ae4f6df8a by Yury Selivanov in branch '3.6': New changeset 8059289b55c1 by Yury Selivanov in branch 'default': |
I've committed the patch with a few touchups:
Andrew, Inada-san, thank you for reviewing the patch! Please take a look at the patch updates referenced below. Feel free to re-open the issue if you see anything suspicious. [1] 1st1@99adc35 [2] 1st1@e294491 [3] 1st1@4d1c50c [4] 1st1@efec03c |
New changeset fb7c439103b9 by Victor Stinner in branch '3.6': |
Since asyncio becomes popular, IMO it is worth to mention this optimization at: Can you please do it Yury? |
Yes, Elvis and I will be the editors of What's New this year anyways ;) |
Python 3.6 & default don't compile on Windows because of the change: http://buildbot.python.org/all/builders/AMD64%20Windows8%203.x/builds/2795/steps/compile/logs/stdio
|
New changeset 635f5854cb3e by Yury Selivanov in branch '3.6': New changeset 9d95510dc203 by Yury Selivanov in branch 'default': |
Pushed a fix for that. |
New changeset db7bcd92cf85 by Yury Selivanov in branch '3.6': New changeset 60b6e820abe5 by Yury Selivanov in branch 'default': |
Looks like that Windows buildbot is green now. Closing. |
New changeset 950fbd75223b by Victor Stinner in branch '3.6': |
Just an FYI, for testing code that has both pure Python and C versions you can follow the advice in https://www.python.org/dev/peps/pep-0399/#details . And if you want to really simplify things you start down the road of what test_importlib uses: https://github.com/python/cpython/blob/master/Lib/test/test_importlib/util.py#L81 . |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: