Skip to main content

Reactive Signals and Computed values.

Project description

Signified

PyPI - Downloads PyPI - Version Tests Status


Documentation: https://dougmercer.github.io/signified

Source Code: https://github.com/dougmercer/signified


A Python library for reactive programming (with kind-of working type narrowing).

Getting started

pip install signified

Why care?

signified is a reactive programming library that implements two primary data structures: Signal and Computed.

Both of these objects implement the Observer and Observable design patterns. This means that they can notify other Observers if they change, and they can subscribe to be notified if another Observable changes.

This allows us to create a network of computation, where one value being modified can trigger other objects to update.

This allows us to write more declarative code, like,

x = Signal(3)
x_squared = x ** 2  # currently equal to 9
x.value = 10  # Will immediately notify x_squared, whose value will become 100.

Here, x_squared became a reactive expression (more specifically, a Computed object) whose value is always equal to x ** 2. Neat!

signified's Signal object effectively gives us a container which stores a value, and Computed gives us a container to store the current value of a function. In the above example, we generated the Computed object on-the-fly using overloaded Python operators like **, but we could have just as easily done,

from signified import computed

@computed
def power(x, n):
    return x**n

x_squared = power(x, 2)  # equivalent to the above

Together, these data structures allow us to implement a wide variety of capabilities. In particular, I wrote this library to make my to-be-released animation library easier to maintain and more fun to work with.

... what do you mean by "kind-of working type narrowing"?

Other reactive Python libraries don't really attempt to implement type hints (e.g., param).

signified is type hinted and supports type narrowing even for nested reactive values.

from signified import Signal

a = Signal(1.0)
b = Signal(Signal(Signal(2)))
reveal_type(a + b)  # Computed[float]

Unfortunately, our type hints only work with pyright.

Ready to learn more?

Checkout the docs at https://dougmercer.github.io/signified or watch my YouTube video about the library.

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

signified-0.3.0.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

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

signified-0.3.0-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file signified-0.3.0.tar.gz.

File metadata

  • Download URL: signified-0.3.0.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for signified-0.3.0.tar.gz
Algorithm Hash digest
SHA256 02b50197bb76062c295f098783302c05a52e24e29c3295a38f58ca4209144175
MD5 5c8e75407cce4c38a585f879ccbdc2f7
BLAKE2b-256 8bae76455dde0f1a811e480eab5511b6a19211ff7717d127efda380c82457bf3

See more details on using hashes here.

Provenance

The following attestation bundles were made for signified-0.3.0.tar.gz:

Publisher: publish.yml on dougmercer/signified

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file signified-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: signified-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for signified-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9803f5033a21d4eb38b1f1f9a2edcc8703c01c305e9f7d8410b3c2339cae556f
MD5 8e5caba045d698debc628bf58103dc42
BLAKE2b-256 442814b20e0cabfbfb1f6827211cfb662fdedb5c7cb08ed365aeacc9f01228d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for signified-0.3.0-py3-none-any.whl:

Publisher: publish.yml on dougmercer/signified

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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