Reactive Signals and Computed values.
Project description
Signified
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 | int]
Unfortunately, for the time being, 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file signified-0.2.3.tar.gz.
File metadata
- Download URL: signified-0.2.3.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3044e323ec454380cbf4935fa0801c2b2051787f22c2116f713ae5b2c8bc2d00
|
|
| MD5 |
57443f5c691cada851964de4706461eb
|
|
| BLAKE2b-256 |
eaafe61220539f291153f82c866f9fd0a62fa6e21b88c5e1cdb2fca1e8caaa46
|
Provenance
The following attestation bundles were made for signified-0.2.3.tar.gz:
Publisher:
publish.yml on dougmercer/signified
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
signified-0.2.3.tar.gz -
Subject digest:
3044e323ec454380cbf4935fa0801c2b2051787f22c2116f713ae5b2c8bc2d00 - Sigstore transparency entry: 193354313
- Sigstore integration time:
-
Permalink:
dougmercer/signified@c5597977de0138e26fa957375948b0eace0f00d1 -
Branch / Tag:
refs/tags/0.2.3 - Owner: https://github.com/dougmercer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c5597977de0138e26fa957375948b0eace0f00d1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file signified-0.2.3-py3-none-any.whl.
File metadata
- Download URL: signified-0.2.3-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d918437f95942aa4735021909526cded66f3518dff295c2963d2d18e417cf045
|
|
| MD5 |
82e836a72a24e4af1a3551b657911d1b
|
|
| BLAKE2b-256 |
1af86e49006d22c1acb035233415f02ef2d4700957ed00b22c72ad70d1bbde32
|
Provenance
The following attestation bundles were made for signified-0.2.3-py3-none-any.whl:
Publisher:
publish.yml on dougmercer/signified
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
signified-0.2.3-py3-none-any.whl -
Subject digest:
d918437f95942aa4735021909526cded66f3518dff295c2963d2d18e417cf045 - Sigstore transparency entry: 193354316
- Sigstore integration time:
-
Permalink:
dougmercer/signified@c5597977de0138e26fa957375948b0eace0f00d1 -
Branch / Tag:
refs/tags/0.2.3 - Owner: https://github.com/dougmercer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c5597977de0138e26fa957375948b0eace0f00d1 -
Trigger Event:
release
-
Statement type: