Skip to main content
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.


Documentation

📖 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.
  • 🔀 Both sync and async support: You can use either sync or async version of QuickSave.
  • 🏎️ 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

If you want use async version of QuickSave:

pip install qsave[async]

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]}

Async version:

from qsave.asyncio import AsyncQuickSave

db = AsyncQuickSave("path/to/your/file.json")

async def main():
    async with db.session(False) as session:
        print(len(session))
        await session.commit()
        await session.rollback()  # NOTE: after commit, rollback does nothing :(
        # only commit and rollback need to be awaited
        # other functionalities remain the same as sync version

License

This repository is licensed under MIT License.

Metadata

Release files for qsave 1.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 qsave 1.1.2
File Size Uploaded Provenance Actions
qsave-1.1.2.tar.gz 5.6 kB Without provenance Details for qsave-1.1.2.tar.gz

Built distribution (wheel)

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

Total release size: 14.7 kB

Release files / qsave-1.1.2.tar.gz

Download URL qsave-1.1.2.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b38fda848b5b7f4f80452033cae4a6548c93cd2c408f1ace13556a96e135d46d
BLAKE2b-256 checksum
How to use checksums
aed7ed8c1040e94d12ee6b501e15c5d3e9a86fcac2b251ecd2951f7ab161d6dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.0 CPython/3.11.6 Windows/10

Release files / qsave-1.1.2-py3-none-any.whl

Download URL qsave-1.1.2-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1b10dc13331ac78ae45afdd38166b31df89e3ef6e95c53a679a699732f9bae3
BLAKE2b-256 checksum
How to use checksums
2889440d5eacd58d2788c9ce28c0769a937664208448424a7ba2aa65e7b5776e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.0 CPython/3.11.6 Windows/10

Security for qsave 1.1.2

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.

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