Skip to main content

SaveState

Coverage Status GitHub Workflow Status PyPI GitHub GitHub Last Commit GitHub Issues Downloads Python Version

pip install savestate

Documentation: https://mrthearman.github.io/savestate/

Source Code: https://github.com/MrThearMan/savestate/

Contributing: 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 module, but aims to be more performant on Windows while being cross-platform compatible.

Savestate is inspired by 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. Note the security implications 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 (linux), but >5000% compared to shelve with 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.

Metadata

Release files for savestate 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for savestate 0.1.2
File Size Uploaded
savestate-0.1.2.tar.gz 12.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for savestate 0.1.2
File Interpreter ABI Platform
savestate-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 26.1 kB

Release files / savestate-0.1.2.tar.gz

Download URL savestate-0.1.2.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
64424da28cd52d540ebf0d9c378772c5ed96d1eaa8e188f255df1e4e3fe8f4d8
BLAKE2b-256 checksum
How to use checksums
ae67af5814a26128e28c9b0aae45f9be38fa89357cb1ad91f589e321a77c54aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.7 Linux/6.2.0-1018-azure

Release files / savestate-0.1.2-py3-none-any.whl

Download URL savestate-0.1.2-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
95affe94b3dc40761173d4a50c7fb1e159f14a6b61ff819c99dbf0cdfc77c841
BLAKE2b-256 checksum
How to use checksums
d4fdc212b43a61b43f65ecedd9f2d94a806398f949c4c1a50256bd3650352f72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.7 Linux/6.2.0-1018-azure

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page