Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

If your application runs only on Linux and macOS, you do not need a platform check around uvloop. Install it, import it, and start the program with uvloop.run(). A check becomes necessary only when the same entry point must also start on Windows, because uvloop’s published package metadata targets macOS and POSIX systems rather than Windows.

When a platform check is actually needed

The check exists to solve one problem: a single codebase that has to start an asyncio event loop on Windows as well as on POSIX. If your deployment targets are Linux servers, Linux containers, or macOS machines, the uvloop import can be unconditional and any branch around it is dead weight. If developers also run the same script on Windows, you need one of the approaches below.

Choosing an approach

Approach Operating systems Who creates the event loop Python and wheel availability Backend-specific APIs
uvloop called directly (uvloop.run()) Linux, macOS, other POSIX systems Your entry point Python >=3.8.1 per the uvloop PyPI metadata; platform-specific distributions are published Available through uvloop
Conditional requirement plus one branch in code Installs uvloop only where the environment marker matches Your entry point, with the branch in code Same as uvloop directly Available through uvloop on POSIX
Third-party selector (winuvloop) Windows (winloop) and POSIX (uvloop) behind one import Your entry point, through the selector Not stated in the package documentation summary; verify before adopting Use the upstream backend directly where the selector’s documentation advises against a wrapper
Framework-managed loop Depends on the framework and deployment platform The framework Not stated Depends on the framework

POSIX-only code: call uvloop.run() directly

  1. Install uvloop into the environment that runs the service with pip install uvloop. The current release on PyPI is 0.23.0, dated October 1, 2026.
  2. Replace asyncio.run(main()) with uvloop.run(main()).
  3. Start the program on a Linux or macOS target and confirm that it runs.
import asyncio
import uvloop

async def main():
    await asyncio.sleep(1)
    print("event loop ready")

uvloop.run(main())

The uvloop project lists uvloop.run() as its preferred usage pattern. Its package description says the helper configures asyncio.run() to use uvloop. Nothing in this code selects a platform, so there is nothing to wrap.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Shared Windows and POSIX entry points

Keep the platform decision out of the install step, but not out of the code

A conditional requirement stops pip from installing uvloop on Windows, which prevents installation failures there. It does not choose the loop. Your entry point still needs one branch, because the Windows path must not call uvloop:

requirements.txt:
uvloop; sys_platform != "win32"

app.py:
import asyncio
import sys

async def main():
    await asyncio.sleep(1)

if sys.platform == "win32":
    asyncio.run(main())
else:
    import uvloop
    uvloop.run(main())

This is the check the title asks you to stop writing. It is valid, and it keeps the dependency footprint minimal, but it does not remove the branch.

Let a selector package own the choice

winuvloop is a third-party package. Its documentation describes a backend map: winloop on Windows, and uvloop on Linux, macOS, and other POSIX systems, behind one import. The package page dates its release to August 24, 2026. This removes the branch from your code, but the selection now belongs to a dependency, so check the following before adopting it:

  • Backend ownership: winloop is the Windows backend in this arrangement, and it is not a Windows backend supplied by uvloop itself. Statements about its behaviour come from winuvloop’s documentation, not from the uvloop maintainers.
  • Python versions: confirm that the interpreters your project targets are covered. The documentation summary available for this article does not establish them.
  • Wheels: if no upstream wheel exists for your platform, installation may fall back to a source build that requires local build tooling. Check this on every OS and interpreter in your build matrix.

Framework-managed event loops

If a web framework or task runner creates the event loop itself, a platform check in your own module may run too late to matter. Install or select the backend before the framework creates the loop, and follow the framework’s documented configuration for custom loops. Test with the exact launch command you use in production, because a loop backend chosen after the framework has already created its loop may not take effect.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When to use the upstream backend directly

Use uvloop or winloop directly when your code calls backend-specific APIs or when you need to debug backend behaviour. In those cases the selector’s documentation says a wrapper is not wanted, so importing the backend by name is the right choice.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What the speed claim covers

uvloop’s project description calls it “a fast, drop-in replacement of the built-in asyncio event loop.” The project also reports a “2–4x faster” figure. That figure comes from the project’s own echo-server benchmark cases covering sockets, streams, and protocols. The year of those benchmarks is not stated on the current PyPI page. The figure is not a prediction for an arbitrary application, and this article cites no independent benchmark. Measure your real workload before and after switching, using the same Python version and the same launch command on both runs.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.