Name | buffr JSON |
Version |
0.0.3
JSON |
| download |
home_page | None |
Summary | Collect objects and apply a function once the buffer is full or expired |
upload_time | 2024-11-04 08:48:04 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
uv
requirements
packaging
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
|
```text
___ __ _____________
/ _ )/ / / / __/ __/ _ \
/ _ / /_/ / _// _// , _/
/____/\____/_/ /_/ /_/|_|
```
# buffr: simple buffering mechanism for Python
| | |
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Testing | ![coverage](https://img.shields.io/codecov/c/github/mike-huls/buffr) |
| Package | [![PyPI Latest Release](https://img.shields.io/pypi/v/buffr.svg)](https://pypi.org/project/buffr/) [![PyPI Downloads](https://img.shields.io/pypi/dm/buffr.svg?label=PyPI%20downloads)](https://pypistats.org/packages/buffr) <br/>![status](https://img.shields.io/pypi/status/buffr) ![dependencies](https://img.shields.io/librariesio/release/pypi/buffr) |
| Meta | ![GitHub License](https://img.shields.io/github/license/mike-huls/buffr) ![implementation](https://img.shields.io/pypi/implementation/buffr) ![versions](https://img.shields.io/pypi/pyversions/buffr) |
| Social | ![tweet](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fgithub.com%2Fmike-huls%2Fbuffr) ![xfollow](https://img.shields.io/twitter/follow/mike_huls?style=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*.
```shell
pip install buffr
```
## Table of Contents
- [Main Features](#main-features)
- [Usage Example](#Usage-example)
- [Installation](#Installation)
- [Dependencies](#Dependencies)
- [License](#license)
- [Documentation](#documentation)
- [Development](#development)
- [Contributing to Buffr](#Development)
## 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.
```python
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:
1. the capacity of 100 items is exceeded
2. 30 seconds pass (`buffr_ttl`)
3. `buffr.flush()` is called
## Installation
```sh
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)](https://pypi.org/project/buffr).
## Dependencies
Buffr has no dependencies
## License
[MIT](LICENSE.txt)
## Documentation
🔨 Under construction
## Development
Find the changelog and list of upcoming features [here](doc/CHANGELOG.md).
<br>
**Contributions** are always welcome; feel free to submit bug reports, bug fixes, feature requests, documentation improvements or enhancements!
<hr>
[Go to Top](#table-of-contents)
Raw data
{
"_id": null,
"home_page": null,
"name": "buffr",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "uv, requirements, packaging",
"author": null,
"author_email": "Mike Huls <mikehuls42@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/1f/95/e048470ea3bb4cfe6786ec9a507b2a65909c863a916874c6a4c7bb02846d/buffr-0.0.3.tar.gz",
"platform": null,
"description": "```text\n ___ __ _____________ \n / _ )/ / / / __/ __/ _ \\\n / _ / /_/ / _// _// , _/\n/____/\\____/_/ /_/ /_/|_| \n```\n\n# buffr: simple buffering mechanism for Python\n| | |\n|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Testing | ![coverage](https://img.shields.io/codecov/c/github/mike-huls/buffr) |\n| Package | [![PyPI Latest Release](https://img.shields.io/pypi/v/buffr.svg)](https://pypi.org/project/buffr/) [![PyPI Downloads](https://img.shields.io/pypi/dm/buffr.svg?label=PyPI%20downloads)](https://pypistats.org/packages/buffr) <br/>![status](https://img.shields.io/pypi/status/buffr) ![dependencies](https://img.shields.io/librariesio/release/pypi/buffr) |\n| Meta | ![GitHub License](https://img.shields.io/github/license/mike-huls/buffr) ![implementation](https://img.shields.io/pypi/implementation/buffr) ![versions](https://img.shields.io/pypi/pyversions/buffr) |\n| Social | ![tweet](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fgithub.com%2Fmike-huls%2Fbuffr) ![xfollow](https://img.shields.io/twitter/follow/mike_huls?style=social) | \n\n**buffr** provides a simple mechanism that allows you to collect values in a buffer. \nOnce a certain time has passed or the buffer's capacity is reached, all values will pe processed with the provided function.\nAs an analogy: don't process each drop, wait till the bucket is full and process *that*.\n\n```shell\npip install buffr\n```\n\n## Table of Contents\n- [Main Features](#main-features)\n- [Usage Example](#Usage-example)\n- [Installation](#Installation)\n- [Dependencies](#Dependencies)\n- [License](#license)\n- [Documentation](#documentation)\n- [Development](#development)\n- [Contributing to Buffr](#Development)\n\n## Main Features\n- \ud83d\udc0d Pure Python\n- \ud83d\udd8c Eadily configurable\n- \ud83d\udc68\u200d\ud83c\udfa8 User-friendly\n\n## Use case\nYou listen to a queue for messages that you'll process and insert into the database.\nIf we receive a message each second, this means that we have to perform an insert 60 times a second. \n\nIn this case we could use Buffr to collect messages for 30 seconds before batch inserting them. \nThis reduces the number of costly database-operations from 60 per minute to just 2.\n\n## Usage Example\nCreating a Buffr is easy.\n```python\nfrom buffr import Buffr\n\n# Define the processor\ndef processing_fn(items:List):\n for item in items:\n print(item * 2)\n\n# Create a buffr\nbuffr = Buffr(max_capacity=100, buffer_ttl=30, flush_func=processing_fn)\n\n# Add some values to the Buffr\nfor i in range(4):\n buffr.add(i)\n```\nThe Buffr defined above will flush in three cases:\n1. the capacity of 100 items is exceeded\n2. 30 seconds pass (`buffr_ttl`)\n3. `buffr.flush()` is called\n\n\n\n\n## Installation\n```sh\npip install buffr\n```\nThe source code is currently hosted on GitHub at:\nhttps://github.com/mike-huls/buffr\n\nBinary installers for the latest released version are available at the [Python\nPackage Index (PyPI)](https://pypi.org/project/buffr).\n\n## Dependencies\nBuffr has no dependencies\n\n## License\n[MIT](LICENSE.txt)\n\n## Documentation\n\ud83d\udd28 Under construction\n\n## Development\nFind the changelog and list of upcoming features [here](doc/CHANGELOG.md).\n<br>\n**Contributions** are always welcome; feel free to submit bug reports, bug fixes, feature requests, documentation improvements or enhancements!\n\n<hr>\n\n[Go to Top](#table-of-contents)\n",
"bugtrack_url": null,
"license": null,
"summary": "Collect objects and apply a function once the buffer is full or expired",
"version": "0.0.3",
"project_urls": {
"Bug Tracker": "https://github.com/mike-huls/cachr/issues",
"Changelog": "https://github.com/mike-huls/cachr/blob/master/CHANGELOG.md/",
"Documentation": "https://github.com/mike-huls/cachr/blob/master/README.md/",
"Homepage": "https://github.com/mike-huls/cachr",
"Say Thanks!": "https://www.buymeacoffee.com/mikehuls",
"Source": "https://github.com/mike-huls/cachr/"
},
"split_keywords": [
"uv",
" requirements",
" packaging"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "bab32f81f361da349014e2ee3f18db862367af40e22b45aae9a42c245215fe29",
"md5": "f25effc3a9d4f28241192e52b3c04555",
"sha256": "50fe15eb82fa4f75d44e85255d14e7669500a107d9de138eca85a3c2e6f31997"
},
"downloads": -1,
"filename": "buffr-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f25effc3a9d4f28241192e52b3c04555",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 4843,
"upload_time": "2024-11-04T08:48:02",
"upload_time_iso_8601": "2024-11-04T08:48:02.696491Z",
"url": "https://files.pythonhosted.org/packages/ba/b3/2f81f361da349014e2ee3f18db862367af40e22b45aae9a42c245215fe29/buffr-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "1f95e048470ea3bb4cfe6786ec9a507b2a65909c863a916874c6a4c7bb02846d",
"md5": "ffb13e1608e4cea116163f7cebea56fb",
"sha256": "dfbc0c863810bd6b77f29e17910a81313671ba4018983a462eda819d39455be6"
},
"downloads": -1,
"filename": "buffr-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "ffb13e1608e4cea116163f7cebea56fb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 5451,
"upload_time": "2024-11-04T08:48:04",
"upload_time_iso_8601": "2024-11-04T08:48:04.183326Z",
"url": "https://files.pythonhosted.org/packages/1f/95/e048470ea3bb4cfe6786ec9a507b2a65909c863a916874c6a4c7bb02846d/buffr-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-04 08:48:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mike-huls",
"github_project": "cachr",
"travis_ci": false,
"coveralls": true,
"github_actions": false,
"lcname": "buffr"
}