Skip to main content

QuickSave is a fast, memory-efficient, and lightweight key-value database.

Project description

QuickSave Banner

QuickSave

Python Version PyPI Version License Total Downloads

QuickSave is a fast, memory-efficient, and lightweight key-value database designed for use in small applications. It operates as a pure Python solution, offering a dictionary-like interface for easy integration. QuickSave works efficiently without dependencies, but if you want to boost its performance even further, you can install msgspec, which significantly enhances its speed.


📖 Table of Contents


Why QuickSave?

QuickSave stands out for its speed, memory efficiency, and simplicity. Here are some of the key reasons you should consider using it:

  • 🚀 High Performance: QuickSave is designed to be fast, with minimal overhead.
  • 💡 Low Memory Usage: The library is optimized for memory efficiency, making it a great choice for projects with limited resources.
  • 🧵 Thread-Safe: It supports thread-safe operations, ensuring that it works reliably in concurrent environments.
  • 🏎️ Boosted Performance with msgspec: By installing the optional msgspec library, you can further enhance QuickSave's performance, especially when handling complex data types.
  • 🔧 No Dependencies: QuickSave is a pure Python library, which means it has no external dependencies, making it easy to install and use in any Python project.

Installation

Install QuickSave using pip:

pip install --upgrade qsave

Optionally, install msgspec to boost performance:

pip install msgspec==0.19.0

Getting Started

To start using QuickSave, import it and initialize your database:

from qsave import QuickSave

db = QuickSave(path="path/to/your/file.json", pretty=True)

The pretty argument beautifies the saved data for better readability (optional).


Examples

Basic Usage

By default, changes are automatically saved when the with block ends:

with db.session() as session:
    session["key"] = "value"
    print(session.get("key"))  # Output: None, not yet saved

# Exiting the block automatically commits changes
with db.session() as session:
    print(session.get("key"))  # Output: value

Manual Commit (commit_on_expire=False)

For full control over when changes are saved, use commit_on_expire=False:

with db.session(commit_on_expire=False) as session:
    session["key"] = "manual_value"
    print(session.get("key"))  # Output: None, not yet saved
    session.commit()  # Now changes are saved
    print(session.get("key"))  # Output: manual_value

with db.session() as session:
    print(session.get("key"))  # Output: manual_value

Commit and Rollback

You can manually save or discard changes during a session:

with db.session() as session:
    session["key"] = "temp_value"
    session.rollback()  # Discard changes
    print(session.get("key"))  # Output: None

Nested Data

with db.session() as session:
    session["nested"] = {"key": [1, 2, 3]}
    session.commit()

with db.session() as session:
    print(session["nested"])  # Output: {"key": [1, 2, 3]}

License

This repository is licensed under MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qsave-1.0.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qsave-1.0.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file qsave-1.0.0.tar.gz.

File metadata

  • Download URL: qsave-1.0.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.11.6 Windows/10

File hashes

Hashes for qsave-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c55f2671efaeba4f98d00f6c76b803c8687cc2c83e2dddf013f014e0e9e0fe43
MD5 b3c43ffe55354ca48283823a4e8edbf2
BLAKE2b-256 51810f227c8a12406da35d3447daa5bbe26137d4c5c0244331156c1dcbfe0a87

See more details on using hashes here.

File details

Details for the file qsave-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: qsave-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.11.6 Windows/10

File hashes

Hashes for qsave-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 25bcc8357fc20aef4910125249bbff474898c5c79f1d3c1d9e7d72c53fcda45b
MD5 d7365484e32492dbdb25b863e41da177
BLAKE2b-256 52ead657b19d86f90b22a2b2b53e17ac489a161d97e9deecc9fe050211d5eb4d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page