fastrlock
Fast, re-entrant optimistic lock implemented in Cython
Decision gist · record as of 2026-08-14
Yes, if you are optimizing a Cython codebase or have profiled threading.RLock as a bottleneck and target Python versions where it remains faster than stdlib. No, if you are on Python 3.4+ and using only the Python API—stdlib RLock is likely as fast or faster. The Cython API is the strongest use case. Install friction is moderate due to compilation, but wheels cover most platforms.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires a C compiler and Python development headers at install time; pre-built wheels available for common platforms but source builds may fail without build tools.
- Medium install friction due to compiled C extensions requiring platform-specific wheels.
- The package maintains broad wheel coverage across Python 2.7 through 3.11+ and multiple architectures (x86_64, i686, aarch64, arm64, Windows).
License · maintenance · safety
MIT style (permissive) — MIT-style permissive license allows commercial and private use with minimal restrictions, typical for low-friction adoption in production systems.
last release 2024-12-17 (605 days) · last repo commit 2024-12-17 · 36 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,221,732 downloads/mo, #4,201 on PyPI
Alternatives
Verify before relying
from fastrlock import rlock
lock = rlock()
with lock:
# critical section
pass- Whether performance gains over threading.RLock remain significant in Python 3.4+ versions where stdlib RLock was substantially optimized.
- Current test coverage and whether the package is actively maintained beyond wheel rebuilds for new Python versions.
- Compatibility guarantees with CPython implementations other than CPython (PyPy, etc.).
What it is and what it does
FastRLock is a Cython-implemented re-entrant lock that serves as a drop-in replacement for threading.RLock. It optimizes for the common case where only one thread holds the lock by avoiding actual lock acquisition until a second thread contends for it, exploiting the GIL to make ownership checks atomic without system-level synchronization overhead.
The package provides both a Python API (compatible with threading.RLock) and a direct Cython C-API for use from other Cython modules. Benchmarks show it can be faster than stdlib RLock in single-threaded scenarios and under light contention, though performance relative to modern Python 3.4+ stdlib implementations varies by CPython version and optimization level. The Cython interface consistently outperforms the Python API by avoiding call overhead.
Use it for
- Replace threading.RLock in latency-sensitive single-threaded or lightly-contended code paths where lock overhead matters.
- Use the Cython C-API from other Cython extensions to avoid Python call overhead in critical sections.
- Embed in libraries like Lupa that require fast, re-entrant synchronization primitives across multiple threads.
- Benchmark-driven optimization where profiling shows threading.RLock as a bottleneck in acquire/release-heavy workloads.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you are optimizing a Cython codebase or have profiled threading.RLock as a bottleneck and target Python versions where it remains faster than stdlib.
No, if you are on Python 3.4+ and using only the Python API—stdlib RLock is likely as fast or faster. The Cython API is the strongest use case. Install friction is moderate due to compilation, but wheels cover most platforms.
Install
fastrlock on PyPI
Before you install
Medium install friction due to compiled C extensions requiring platform-specific wheels. The package maintains broad wheel coverage across Python 2.7 through 3.11+ and multiple architectures (x86_64, i686, aarch64, arm64, Windows). Last release was 605 days ago; repository is not archived and remains active.
Requires a C compiler and Python development headers at install time; pre-built wheels available for common platforms but source builds may fail without build tools.
License in practice
MIT-style permissive license allows commercial and private use with minimal restrictions, typical for low-friction adoption in production systems.
Quickstart
from fastrlock import rlock
lock = rlock()
with lock:
# critical section
pass
Verify before relying
- Whether performance gains over threading.RLock remain significant in Python 3.4+ versions where stdlib RLock was substantially optimized.
- Current test coverage and whether the package is actively maintained beyond wheel rebuilds for new Python versions.
- Compatibility guarantees with CPython implementations other than CPython (PyPy, etc.).
Package facts
| License | MIT style permissive |
| Python support | Not specified |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | None |
| Maintenance | Dormant 605 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,221,732 / month, #4,201 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Information TechnologyLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: CythonProgramming Language :: Python :: 3Topic :: Software Development |
Evidence: fastrlock-0.8.3-cp27-cp27m-manylinux_2_5_i686.manylinux1_i686.whl; fastrlock-0.8.3-cp27-cp27m-manylinux_2_5_x86_64.manylinux1_x86_64.whl; fastrlock-0.8.3-cp27-cp27mu-manylinux_2_5_i686.manylinux1_i686.whl; fastrlock-0.8.3-cp27-cp27mu-manylinux_2_5_x86_64.manylinux1_x86_64.whl; fastrlock-0.8.3-cp310-cp310-macosx_11_0_universal2.whl; fastrlock-0.8.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl; fastrlock-0.8.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_24_i686.whl; fastrlock-0.8.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_24_x86_64.whl; fastrlock-0.8.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl; fastrlock-0.8.3-cp310-cp310-musllinux_1_1_aarch64.whl; fastrlock-0.8.3-cp310-cp310-musllinux_1_1_x86_64.whl; fastrlock-0.8.3-cp310-cp310-win_amd64.whl; fastrlock-0.8.3-cp311-cp311-macosx_11_0_universal2.whl; fastrlock-0.8.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl; fastrlock-0.8.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_24_i686.whl; fastrlock-0.8.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_24_x86_64.whl; fastrlock-0.8.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl; fastrlock-0.8.3-cp311-cp311-musllinux_1_1_aarch64.whl; fastrlock-0.8.3-cp311-cp311-musllinux_1_1_x86_64.whl; fastrlock-0.8.3-cp311-cp311-win_amd64.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “fast reentrant lock”
- fastrlockA C-level re-entrant lock for CPython that replaces threading.RLock…
- aiorwlockProvides read-write locks for asyncio programs, allowing multiple…
- django-pglockProvides Postgres advisory locks, table locks, and lock management…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also redlock-py · aiorwlock · fasteners · filelock · redlock · locket · python-redis-lock · python-dynamodb-lock · PyMySQLLock · gilknocker