I'm not sure if aiofiles is stable or not, but I would like the actual implementation to be slightly different. aiofiles simply proxies all file IO operations through a thread pool, but there are better alternatives in some cases. Using a thread pool is totally fine for vanilla asyncio, but there should be a way for projects like uvloop/twisted to inject their own implementation of asynchronous file IO.
To do that we probably need to define an abstract file IO interface and add a method to event loop to return an object that implements that interface. For instance:
# in asyncio:
async def open(self):
async def open(...):
return await get_current_loop(). get_file_io_implementation().open(...)
# in uvloop or twisted or ...:
# ... implementation of "open()"
# later in user code:
async def main():
file = await asyncio.open(...)