# SaveState
[![Coverage Status][coverage-badge]][coverage]
[![GitHub Workflow Status][status-badge]][status]
[![PyPI][pypi-badge]][pypi]
[![GitHub][licence-badge]][licence]
[![GitHub Last Commit][repo-badge]][repo]
[![GitHub Issues][issues-badge]][issues]
[![Downloads][downloads-badge]][pypi]
[![Python Version][version-badge]][pypi]
```shell
pip install savestate
```
---
**Documentation**: [https://mrthearman.github.io/savestate/](https://mrthearman.github.io/savestate/)
**Source Code**: [https://github.com/MrThearMan/savestate/](https://github.com/MrThearMan/savestate/)
**Contributing**: [https://github.com/MrThearMan/savestate/blob/main/CONTRIBUTING.md](https://github.com/MrThearMan/savestate/blob/main/CONTRIBUTING.md)
---
SaveState is a cross-platform fast file storage for arbitrary python objects.
It's similar to python's builtin [shelve][shelve] module, but aims to be more
performant on Windows while being cross-platform compatible.
Savestate is inspired by [semidbm2][semidbm2], with a more modern interface.
mapping-like functions, a context manager, and support for
arbitrary python objects.
### Implementation details:
- Pure python
- No requirements or dependencies
- A dict-like interface (no unions)
- Same, single file on Windows and Linux (unlike shelve)
- Key and value integrity can be evaluated with a checksum, which will detect data corruption on key access.
- Recovery from missing bytes at the end of the file, or small amounts of corrupted data in the middle
- Both values AND keys put in savestate must support [pickling][pickling].
Note the [security implications][security] of this!
- This means that you can use arbitrary objects as keys if they support pickle (unlike shelve)
- All the keys of the savestate are kept in memory, which limits the savestate size (not a problem for most applications)
- NOT Thread safe, so cannot be accessed by multiple processes
- File is append-only, so the more non-read operations you do, the more the file size is going to balloon
- However, you can *compact* the savestate, usually on *savestate.close()*, which will replace the savestate with a new file with only the current non-deleted data.
This will impact performance a little, but not by much
### Performance:
- About 50-60% of the performance of shelve with [gdbm][gdbm] (linux),
but >5000% compared to shelve with [dumbdbm][dumbdbm] (windows) (>20000% for deletes!)
- Performance is more favorable with large keys and values when compared to gdbm,
but gdbm is still faster on subsequent reads/writes thanks to its caching
- A dbm-mode for about double the speed of regular mode, but only string-type keys and values
- This is about 25-30% of the performance of gdbm on its own.
- Note: Values will be returned in bytes form!
> Source code includes a benchmark that you can run to get more accurate performance on your specific machine.
[shelve]: https://docs.python.org/3/library/shelve.html
[semidbm2]: https://github.com/quora/semidbm2
[pickling]: https://docs.python.org/3/library/pickle.html#module-pickle
[security]: https://docs.python.org/3/library/pickle.html#module-pickle
[gdbm]: https://docs.python.org/3/library/dbm.html#module-dbm.gnu
[dumbdbm]: https://docs.python.org/3/library/dbm.html#module-dbm.dumb
[coverage-badge]: https://coveralls.io/repos/github/MrThearMan/savestate/badge.svg?branch=main
[downloads-badge]: https://img.shields.io/pypi/dm/savestate
[status-badge]: https://img.shields.io/github/actions/workflow/status/MrThearMan/savestate/test.yml?branch=main
[pypi-badge]: https://img.shields.io/pypi/v/savestate
[licence-badge]: https://img.shields.io/github/license/MrThearMan/savestate
[repo-badge]: https://img.shields.io/github/last-commit/MrThearMan/savestate
[issues-badge]: https://img.shields.io/github/issues-raw/MrThearMan/savestate
[version-badge]: https://img.shields.io/pypi/pyversions/savestate
[coverage]: https://coveralls.io/github/MrThearMan/savestate?branch=main
[status]: https://github.com/MrThearMan/savestate/actions/workflows/test.yml
[pypi]: https://pypi.org/project/savestate
[licence]: https://github.com/MrThearMan/savestate/blob/main/LICENSE
[repo]: https://github.com/MrThearMan/savestate/commits/main
[issues]: https://github.com/MrThearMan/savestate/issues
Raw data
{
"_id": null,
"home_page": "https://mrthearman.github.io/savestate/",
"name": "savestate",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9,<4",
"maintainer_email": "",
"keywords": "savestate",
"author": "Matti Lamppu",
"author_email": "lamppu.matti.akseli@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ae/67/af5814a26128e28c9b0aae45f9be38fa89357cb1ad91f589e321a77c54aa/savestate-0.1.2.tar.gz",
"platform": null,
"description": "# SaveState\n\n[![Coverage Status][coverage-badge]][coverage]\n[![GitHub Workflow Status][status-badge]][status]\n[![PyPI][pypi-badge]][pypi]\n[![GitHub][licence-badge]][licence]\n[![GitHub Last Commit][repo-badge]][repo]\n[![GitHub Issues][issues-badge]][issues]\n[![Downloads][downloads-badge]][pypi]\n[![Python Version][version-badge]][pypi]\n\n```shell\npip install savestate\n```\n\n---\n\n**Documentation**: [https://mrthearman.github.io/savestate/](https://mrthearman.github.io/savestate/)\n\n**Source Code**: [https://github.com/MrThearMan/savestate/](https://github.com/MrThearMan/savestate/)\n\n**Contributing**: [https://github.com/MrThearMan/savestate/blob/main/CONTRIBUTING.md](https://github.com/MrThearMan/savestate/blob/main/CONTRIBUTING.md)\n\n---\n\nSaveState is a cross-platform fast file storage for arbitrary python objects.\nIt's similar to python's builtin [shelve][shelve] module, but aims to be more\nperformant on Windows while being cross-platform compatible.\n\nSavestate is inspired by [semidbm2][semidbm2], with a more modern interface.\nmapping-like functions, a context manager, and support for\narbitrary python objects.\n\n### Implementation details:\n- Pure python\n- No requirements or dependencies\n- A dict-like interface (no unions)\n- Same, single file on Windows and Linux (unlike shelve)\n- Key and value integrity can be evaluated with a checksum, which will detect data corruption on key access.\n- Recovery from missing bytes at the end of the file, or small amounts of corrupted data in the middle\n- Both values AND keys put in savestate must support [pickling][pickling].\nNote the [security implications][security] of this!\n - This means that you can use arbitrary objects as keys if they support pickle (unlike shelve)\n- All the keys of the savestate are kept in memory, which limits the savestate size (not a problem for most applications)\n- NOT Thread safe, so cannot be accessed by multiple processes\n- File is append-only, so the more non-read operations you do, the more the file size is going to balloon\n - However, you can *compact* the savestate, usually on *savestate.close()*, which will replace the savestate with a new file with only the current non-deleted data.\n This will impact performance a little, but not by much\n\n### Performance:\n- About 50-60% of the performance of shelve with [gdbm][gdbm] (linux),\n but >5000% compared to shelve with [dumbdbm][dumbdbm] (windows) (>20000% for deletes!)\n - Performance is more favorable with large keys and values when compared to gdbm,\n but gdbm is still faster on subsequent reads/writes thanks to its caching\n- A dbm-mode for about double the speed of regular mode, but only string-type keys and values\n - This is about 25-30% of the performance of gdbm on its own.\n - Note: Values will be returned in bytes form!\n\n> Source code includes a benchmark that you can run to get more accurate performance on your specific machine.\n\n\n[shelve]: https://docs.python.org/3/library/shelve.html\n[semidbm2]: https://github.com/quora/semidbm2\n[pickling]: https://docs.python.org/3/library/pickle.html#module-pickle\n[security]: https://docs.python.org/3/library/pickle.html#module-pickle\n[gdbm]: https://docs.python.org/3/library/dbm.html#module-dbm.gnu\n[dumbdbm]: https://docs.python.org/3/library/dbm.html#module-dbm.dumb\n\n[coverage-badge]: https://coveralls.io/repos/github/MrThearMan/savestate/badge.svg?branch=main\n[downloads-badge]: https://img.shields.io/pypi/dm/savestate\n[status-badge]: https://img.shields.io/github/actions/workflow/status/MrThearMan/savestate/test.yml?branch=main\n[pypi-badge]: https://img.shields.io/pypi/v/savestate\n[licence-badge]: https://img.shields.io/github/license/MrThearMan/savestate\n[repo-badge]: https://img.shields.io/github/last-commit/MrThearMan/savestate\n[issues-badge]: https://img.shields.io/github/issues-raw/MrThearMan/savestate\n[version-badge]: https://img.shields.io/pypi/pyversions/savestate\n\n[coverage]: https://coveralls.io/github/MrThearMan/savestate?branch=main\n[status]: https://github.com/MrThearMan/savestate/actions/workflows/test.yml\n[pypi]: https://pypi.org/project/savestate\n[licence]: https://github.com/MrThearMan/savestate/blob/main/LICENSE\n[repo]: https://github.com/MrThearMan/savestate/commits/main\n[issues]: https://github.com/MrThearMan/savestate/issues\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Persistent storage of arbitrary python objects",
"version": "0.1.2",
"project_urls": {
"Bug Tracker": "https://github.com/MrThearMan/savestate/issues",
"Homepage": "https://mrthearman.github.io/savestate/",
"Repository": "https://github.com/MrThearMan/savestate"
},
"split_keywords": [
"savestate"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d4fdc212b43a61b43f65ecedd9f2d94a806398f949c4c1a50256bd3650352f72",
"md5": "06e548834c18205faddf504591fdd5b9",
"sha256": "95affe94b3dc40761173d4a50c7fb1e159f14a6b61ff819c99dbf0cdfc77c841"
},
"downloads": -1,
"filename": "savestate-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "06e548834c18205faddf504591fdd5b9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9,<4",
"size": 13329,
"upload_time": "2023-12-30T11:18:11",
"upload_time_iso_8601": "2023-12-30T11:18:11.623595Z",
"url": "https://files.pythonhosted.org/packages/d4/fd/c212b43a61b43f65ecedd9f2d94a806398f949c4c1a50256bd3650352f72/savestate-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ae67af5814a26128e28c9b0aae45f9be38fa89357cb1ad91f589e321a77c54aa",
"md5": "076713ac0824725233e59c563b17d154",
"sha256": "64424da28cd52d540ebf0d9c378772c5ed96d1eaa8e188f255df1e4e3fe8f4d8"
},
"downloads": -1,
"filename": "savestate-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "076713ac0824725233e59c563b17d154",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9,<4",
"size": 12769,
"upload_time": "2023-12-30T11:18:13",
"upload_time_iso_8601": "2023-12-30T11:18:13.119858Z",
"url": "https://files.pythonhosted.org/packages/ae/67/af5814a26128e28c9b0aae45f9be38fa89357cb1ad91f589e321a77c54aa/savestate-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-30 11:18:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "MrThearMan",
"github_project": "savestate",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "savestate"
}