___ __ _____________
/ _ )/ / / / __/ __/ _ \
/ _ / /_/ / _// _// , _/
/____/\____/_/ /_/ /_/|_|
buffr: simple buffering mechanism for Python
| Testing | |
| Package | |
| Meta | |
| Social |
buffr provides a simple mechanism that allows you to collect values in a buffer. Once a certain time has passed or the buffer's capacity is reached, all values will pe processed with the provided function. As an analogy: don't process each drop, wait till the bucket is full and process that.
pip install buffr
Table of Contents
- Main Features
- Usage Example
- Installation
- Dependencies
- License
- Documentation
- Development
- Contributing to Buffr
Main Features
- 🐍 Pure Python
- 🖌 Eadily configurable
- 👨🎨 User-friendly
Use case
You listen to a queue for messages that you'll process and insert into the database. If we receive a message each second, this means that we have to perform an insert 60 times a second.
In this case we could use Buffr to collect messages for 30 seconds before batch inserting them. This reduces the number of costly database-operations from 60 per minute to just 2.
Usage Example
Creating a Buffr is easy.
from buffr import Buffr
# Define the processor
def processing_fn(items:List):
for item in items:
print(item * 2)
# Create a buffr
buffr = Buffr(max_capacity=100, buffer_ttl=30, flush_func=processing_fn)
# Add some values to the Buffr
for i in range(4):
buffr.add(i)
The Buffr defined above will flush in three cases:
- the capacity of 100 items is exceeded
- 30 seconds pass (
buffr_ttl) buffr.flush()is called
Installation
pip install buffr
The source code is currently hosted on GitHub at: https://github.com/mike-huls/buffr
Binary installers for the latest released version are available at the Python Package Index (PyPI).
Dependencies
Buffr has no dependencies
License
Documentation
🔨 Under construction
Development
Find the changelog and list of upcoming features here.
Contributions are always welcome; feel free to submit bug reports, bug fixes, feature requests, documentation improvements or enhancements!
Metadata
Release files for buffr 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| buffr-0.0.3.tar.gz | 5.5 kB | Without provenance | Details for buffr-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| buffr-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for buffr-0.0.3-py3-none-any.whl |
Total release size: 10.3 kB
Release files / buffr-0.0.3.tar.gz
| Download URL | buffr-0.0.3.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dfbc0c863810bd6b77f29e17910a81313671ba4018983a462eda819d39455be6
|
|
BLAKE2b-256 checksum How to use checksums |
1f95e048470ea3bb4cfe6786ec9a507b2a65909c863a916874c6a4c7bb02846d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.4.29
|
Release files / buffr-0.0.3-py3-none-any.whl
| Download URL | buffr-0.0.3-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
50fe15eb82fa4f75d44e85255d14e7669500a107d9de138eca85a3c2e6f31997
|
|
BLAKE2b-256 checksum How to use checksums |
bab32f81f361da349014e2ee3f18db862367af40e22b45aae9a42c245215fe29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.4.29
|
Security for buffr 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.