{"action":"created","issue":{"url":"https://api.github.com/repos/python/asyncio/issues/282","labels_url":"https://api.github.com/repos/python/asyncio/issues/282/labels{/name}","comments_url":"https://api.github.com/repos/python/asyncio/issues/282/comments","events_url":"https://api.github.com/repos/python/asyncio/issues/282/events","html_url":"https://github.com/python/asyncio/issues/282","id":114505193,"number":282,"title":"ABC for Futures","user":{"login":"1st1","id":239003,"avatar_url":"https://avatars.githubusercontent.com/u/239003?v=3","gravatar_id":"","url":"https://api.github.com/users/1st1","html_url":"https://github.com/1st1","followers_url":"https://api.github.com/users/1st1/followers","following_url":"https://api.github.com/users/1st1/following{/other_user}","gists_url":"https://api.github.com/users/1st1/gists{/gist_id}","starred_url":"https://api.github.com/users/1st1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/1st1/subscriptions","organizations_url":"https://api.github.com/users/1st1/orgs","repos_url":"https://api.github.com/users/1st1/repos","events_url":"https://api.github.com/users/1st1/events{/privacy}","received_events_url":"https://api.github.com/users/1st1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-11-02T00:45:08Z","updated_at":"2015-11-12T08:22:19Z","closed_at":null,"body":"I'm experimenting with implementing an asyncio-compatible event loop on top of libuv with Cython. It would be great if there is a way to provide a custom Future implementation.  I was thinking about adding `loop.create_future()` (instead of `Future(loop=loop)`) API method, as well as an ABC, so that functions like `ensure_future` would recognize custom Futures.  @gvanrossum @haypo what do you think about this?"},"comment":{"url":"https://api.github.com/repos/python/asyncio/issues/comments/156031717","html_url":"https://github.com/python/asyncio/issues/282#issuecomment-156031717","issue_url":"https://api.github.com/repos/python/asyncio/issues/282","id":156031717,"user":{"login":"haypo","id":194129,"avatar_url":"https://avatars.githubusercontent.com/u/194129?v=3","gravatar_id":"","url":"https://api.github.com/users/haypo","html_url":"https://github.com/haypo","followers_url":"https://api.github.com/users/haypo/followers","following_url":"https://api.github.com/users/haypo/following{/other_user}","gists_url":"https://api.github.com/users/haypo/gists{/gist_id}","starred_url":"https://api.github.com/users/haypo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haypo/subscriptions","organizations_url":"https://api.github.com/users/haypo/orgs","repos_url":"https://api.github.com/users/haypo/repos","events_url":"https://api.github.com/users/haypo/events{/privacy}","received_events_url":"https://api.github.com/users/haypo/received_events","type":"User","site_admin":false},"created_at":"2015-11-12T08:22:19Z","updated_at":"2015-11-12T08:22:19Z","body":"Hum, I'm not sure that we want an ABC here. Yury proposes a C accelerator module for asyncio. I really like this idea, I had the same idea many times (I tried to implement a free list for the Task class, but I didn't see any difference in performance). I know that writing the same code with the Python C API makes the code faster (I don't understand why, it's just a fact :-)).\r\n\r\nIMHO we need an _asyncio module which implements some functions and classes of asyncio, but keep the Python implementation for other Python VMs (PyPy & cie). And then use the classic \"try: from _asyncio import Future except ImportError: Future = PyFuture\".\r\n\r\n--\r\n\r\n\"Calling asyncio.Future(loop=loop) isn't much different from loop.create_future(). The latter form is less error prone, since the future will always be attached to the correct loop.\"\r\n\r\nWe can consider this as a different issue. For me, it's a an API enhancement to make the loop \"parameter\" mandatory (and it might be a little bit faster, no need to get asyncio.get_event_loop()). The drawback is that you have to pass loop to a lot of functions. I don't know if users like the implicit loop parameter. Maybe passing explicitly the loop parameter matters more when you have multiple event loops running in different threads? (but asyncio.get_event_loop() handles this use case thanks to thread local storage).\r\n\r\nI'm ok to add loop.create_future() and try to use it in asyncio core, but I'm not sure yet that we really must to replace all Future(loop=loop) with loop.create_future(). As the addition of loop.create_task(), it also creates a problem with backward compatibility. To write code working with asyncio of Python 3.4.0 stdlib, create_task() and create_future() cannot be used... as await/async keywords..."}}