Skip to main content

✅ upd8

Version tracking for Python classes

🍐 wut?

Give your objects a version number that updates when you make changes.

⬇️ installation

pip install upd8
or
uv pip install upd8

▶️ Usage

Simple updates

>>> import upd8
>>> v = upd8.Versioned()
>>> v.version
0
>>> v.change()
1
>>> v.change()
2

Automatic versioning

Fields will update the version when you change them.

from upd8 import Versioned, field

class Doggo(Versioned):
    name = field("Pupper")
    legs = field(4)
>>> d = Doggo()
>>> d.legs -= 1
>>> d.name = "Tripod"
>>> d.version
2

Manual updates

change can be used as a context manager, and changes can be aborted by raising AbortChange:

>>> from upd8 import
>>> d = Doggo()
>>> d.legs = 1
>>> with d.change:
        if not d.legs:
            raise AbortChange()
        d.legs -= 1
>>> d.version
1

You can use async with Versioned.change from within asynchronous code.

Thread safety

If you're not using automatic updating fields, you can add thread safety to Versioned objects by decorating method with @waits, and avoid the context manager indenting your code with the @changes.

These work on async methods too.

class World(Versioned):
    _population: int = 8_000_000_000

    @changes
    def bottleneck(self, amount: float) -> int:
        survivors = int(self._population * amount)
        if survivors <= 0 or survivors == self._population:

            # set the return value in the AbortChange exception
            raise AbortChange(self._population)

        self._population = survivors
        return self._population

    @waits
    @property
    def population(self):
        return self._population

🔗 links

⚖️ License

Licensed under the WTFPL with one additional clause:

  1. Don't blame me.

Release files for upd8 0.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 upd8 0.0.2
File Size Uploaded
upd8-0.0.2.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for upd8 0.0.2
File Interpreter ABI Platform
upd8-0.0.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 9.9 kB

Release files / upd8-0.0.2.tar.gz

Download URL upd8-0.0.2.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ceceb4e22fed4ff1d506b007e2fb8d12f09d178955dcd9033dc1d69b6696c1a2
BLAKE2b-256 checksum
How to use checksums
97b0cef5cd4a4bc9df62053770f8ebb783c854e5e39412dc07be2329551cc412
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / upd8-0.0.2-py2.py3-none-any.whl

Download URL upd8-0.0.2-py2.py3-none-any.whl
Size 5.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
85153ccafcbf3948b3000ee856b0b7766b0f40ea8ff8ca15b2621162732841a3
BLAKE2b-256 checksum
How to use checksums
f06b76ce057b45d48087f1c13881fcd6c4be446c4295c44bdb36e0b0e5991bc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.2 This release

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