uvloop makes asyncio 2-4x faster.
blog post about it.uvloop requires Python 3.8 or greater and is available on PyPI. Use pip to install it:
$ pip install uvloop
Note that it is highly recommended to upgrade pip before installing uvloop with:
$ pip install -U pip
As of uvloop 0.18, the preferred way of using it is via the
uvloop.run() helper function:
import uvloop
async def main():
# Main entry-point.
...
uvloop.run(main())
uvloop.run() works by simply configuring asyncio.run()
to use uvloop, passing all of the arguments to it, such as debug,
e.g. uvloop.run(main(), debug=True).
With Python 3.11 and earlier the following alternative snippet can be used:
import asyncio
import sys
import uvloop
async def main():
# Main entry-point.
...
if sys.version_info >= (3, 11):
with asyncio.Runner(loop_factory=uvloop.new_event_loop) as runner:
runner.run(main())
else:
uvloop.install()
asyncio.run(main())
To build uvloop, you'll need Python 3.8 or greater:
Clone the repository:
$ git clone --recursive git@github.com:MagicStack/uvloop.git $ cd uvloop
Create a virtual environment and activate it:
$ python3 -m venv uvloop-dev $ source uvloop-dev/bin/activate
Install development dependencies:
$ pip install -e .[dev]
Build and run tests:
$ make $ make test
uvloop is dual-licensed under MIT and Apache 2.0 licenses.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。