Registry / testing / librt
library0.15.0pypypi✓ verified 25d ago

librt is the Mypyc runtime library, providing efficient C implementations of various Python standard library classes and functions. Mypyc leverages this library to produce faster C extensions when compiling Python code. It is primarily an internal dependency for `mypyc` and `mypy` (since version 1.19.0 for fixed-format cache serialization). The current version is 0.8.1, with development occurring in the main `mypy` repository and releases synced to the `librt` PyPI package.

pip install librt
INSTALL
IMPORT
SIG · LIBRT
L
librt
testingpythonv0.15.0
Install
1.9s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.15.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.9s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

librt
This library is primarily an internal runtime dependency for mypyc-compiled code and recent versions of mypy. Direct import of its internal symbols by end-user applications is generally not intended.
librt provides C implementations used by mypyc-generated extensions. While Python might theoretically allow importing internal parts (e.g., `librt.internal`), this is not part of its public API and can lead to unexpected issues or breaking changes. For example, `mypy` itself uses `librt` for cache serialization and deserialization, often through internal mechanisms rather than direct `import librt` in user code.

librt is a runtime library for code compiled with `mypyc`. Therefore, its 'quickstart' involves demonstrating how to use `mypyc` to compile Python code. The compiled code will then depend on `librt` at runtime. The example shows a simple Python function that `mypyc` could compile, implicitly leveraging `librt`'s optimizations.

# librt is implicitly used by mypyc-compiled modules. # A typical quickstart involves using mypyc, which then utilizes librt. # First, ensure librt (and mypy, which includes mypyc) are installed. # pip install mypy mypyc # example_module.py # This module will be compiled by mypyc, which relies on librt at runtime. def factorial(n: int) -> int: result = 1 for i in range(1, n + 1): result *= i return result if __name__ == '__main__': # In a real scenario, this would be compiled and imported as a C extension. # For illustration, let's just run it as normal Python. # To compile: mypyc example_module.py # This creates a C extension (e.g., example_module.cpython-XYZ.so) that depends on librt. print(f'Factorial of 5: {factorial(5)}')
Debug
Known issues
breakinglibrt does not officially support PyPy. If your project targets PyPy and has `librt` as a dependency (e.g., through `mypy` for type checking), you may need to skip it in your CI matrix for PyPy environments.
fix
Avoid using librt-dependent components in PyPy environments or configure CI to exclude librt-related checks/builds for PyPy.
affects: All versions
gotchalibrt's Application Binary Interface (ABI) is not explicitly versioned, and changes to it can lead to compatibility issues with `mypyc`-compiled extensions. This can cause breakage if `librt` is updated independently of `mypyc` or the compiled application.
fix
Ensure `librt` is kept in sync with the `mypyc` version used for compilation. Pinning exact versions of `librt` and `mypyc` is recommended, especially in production environments or when distributing `mypyc`-compiled code.
affects: All versions
gotchalibrt is primarily an internal runtime component. Direct imports or reliance on its internal API in user-facing Python code are discouraged, as these interfaces are subject to change without standard deprecation warnings.
fix
Treat librt as an implementation detail of mypyc. Do not directly import or use symbols from `librt` in your application code; instead, rely on the behavior of `mypyc`-compiled modules.
affects: All versions
deprecatedMypy 1.19.0 introduced `librt` as a dependency for its fixed-format cache serialization. Older versions of `mypy` (before 1.19.0) did not require `librt` for this purpose, relying instead on JSON-based caching.
fix
If upgrading `mypy` to 1.19.0 or newer, ensure `librt` is installed alongside it. For older `mypy` versions, `librt` is not required for cache functionality.
affects: <1.19.0 (mypy)
Upgrade
Version history
0.15.0latest on PyPI · released Aug 7, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
Resources