FastCounter
raw JSON → 1.2.0 verified Sat May 09 auth: no python
A Python library providing fast, thread-safe counter implementations. Currently at version 1.2.0 with type hints added. Active development on GitHub.
pip install fastcounter Common errors
error AttributeError: 'FastReadCounter' object has no attribute 'increment' ↓
cause Using FastReadCounter in a context where incrementing is needed.
fix
Replace
FastReadCounter with FastWriteCounter. error ImportError: cannot import name 'Counter' from 'fastcounter' ↓
cause The module was renamed or removed. There is no `Counter` in fastcounter.
fix
Use
from fastcounter import FastWriteCounter or FastReadCounter. Warnings
breaking Version 1.2.0 added type hints; if you were relying on dynamic attribute access or duck typing, your code may break under strict type checkers. ↓
fix Update your code to match the type signatures. For example, `increment()` now returns `None` explicitly.
deprecated The `Counter` base class (if exists) is deprecated in favor of `FastWriteCounter` and `FastReadCounter`. ↓
fix Replace `from fastcounter import Counter` with `from fastcounter import FastWriteCounter` (or FastReadCounter) and adjust usage accordingly.
gotcha `FastReadCounter` does not support `increment()`; it only provides `value()`. Trying to call `increment()` will raise an AttributeError. ↓
fix Ensure you import the correct counter type: use `FastWriteCounter` for counting operations, `FastReadCounter` for read-only access.
Imports
- FastWriteCounter
from fastcounter import FastWriteCounter - FastReadCounter
from fastcounter import FastReadCounter
Quickstart
from fastcounter import FastWriteCounter
counter = FastWriteCounter()
counter.increment()
counter.add(5)
print(counter.value())