--- id: fastrlock version: "0.8.3" license: MIT style license_treatment: permissive maintenance: dormant --- # fastrlock — Fast, re-entrant optimistic lock implemented in Cython License: permissive · Maintenance: dormant · Downloads: 1.2M/mo ## 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 above — verify before relying. A C-level re-entrant lock for CPython that replaces threading.RLock with faster acquire/release cycles through optimistic locking and Cython implementation. 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 pip install fastrlock uv add fastrlock poetry add fastrlock ## Installing fastrlock 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. 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 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. 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: unspecified - Install friction: medium - Maintenance: dormant - Downloads: 1.2M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags fast reentrant lock, threading rlock replacement, cython lock implementation, optimistic locking python, high-performance mutex, thread synchronization, concurrent access control, concurrency, cython-extension, performance-critical [View on SkillFed](https://skillfed.io/packages/fastrlock) · [View on PyPI](https://pypi.org/project/fastrlock/)