Skip to main content

cowdict is a python module implementing copy-on-write pattern on dictionaries.

This means that if someone change the dict-like object, the original object won’t be changed but the differences will be tracked instead.

Nutshell

Here’s a small example:

base_dict = {"foo": "bar"}
cd = CowDict(base_dict)
cd["foo"] = "baz"

print(base_dict["foo"]) # will still print 'bar'
print(cd["foo"]) # will print 'baz'

CowDict object (cd in the code above) implements the MutableMapping interface, simply speaking it has the same interface as the dict object.

This means that it is guaranteed that changing keys/values on this object will never cause the change of the underlying dictionary (base_dict in the example).

Philosophy

The idea behind this module is to avoid copying dictionary where it is possible and use this wrapper class instead. While it has some penalties on the performance on key lookup and length calculation, the memory footprint can be kept at minimum (compared to a full copy of the dictionary).

Behind the scenes

Behind the scenes, new items are added to a separate directory. Keys which exist on the base dictionary are ‘deleted’ by keeping a separate set object about the the keys deleted. Every time when a key is accessed either by getitem or items or other methods, these additional structures are involved to produce the correct result.

While having an assumption of having the base dictionary read-only would make the world easier, especially when calculating the length of the object, the library handles the situation when the base dictionary changes.

Metadata

Release files for cowdict 0.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 cowdict 0.2
File Size Uploaded Provenance
cowdict-0.2.tar.gz 2.5 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 6.9 kB

Release files / cowdict-0.2.tar.gz

Download URL cowdict-0.2.tar.gz
Size 2.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ee21a35f43ab9f8ad205121220b020aba1342e5285f230bb7110953809d38703
BLAKE2b-256 checksum
How to use checksums
ee0ceff9b399cb8311235fceb85a194b7ff973a7833efee5db2f47459403d979
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / cowdict-0.2-py3-none-any.whl

Download URL cowdict-0.2-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46d9d19b52451e55857f0bc02403d912aa731da288938dea374558469f955195
BLAKE2b-256 checksum
How to use checksums
cd9a3220db473587729fcd02175f368cba92ec9d4e9130034a6ae798b3fa8d4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for cowdict 0.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.

Release history Release notifications | RSS feed

This release

0.2 This release

2 release files No provenance

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