Primitives for transparent reactive programming in Python
Project description
signals
primitives for transparent reactive programming in python
install
pip install signals
usage
from signals import Signal, effect
a = Signal(0)
b = Signal(2)
def c():
return a() + b()
print(c()) # 2
a.set(1)
print(c()) # 3
b.set(3)
print(c()) # 4
# Log the values of a, b, c whenever one changes
@effect
def log_abc():
print(a(), b(), c())
a.set(2) # prints (2, 3, 5)
cell magic
we also provide a ipython cell magic %%effect, which offers a convenient way
re-execute cells that use signals.
In[1]:
%load_ext signals
from signals import Signal
a = Signal(0)
b = Signal(2)
In[2]:
%%effect
a() + b() # re-evaluates the cell whenever a or b changes
In[3]:
a.set(1)
what
signals is an implementation of transparent reactive programming (TRP) for
Python.
TRP is a declarative programming paradigm for expressing relationships between values that vary over time. These time-varying values are known as signals. Whenever a signal changes, the system automatically updates all dependents.
Spreadsheets are the classic example of TRP: cells linked by formulas update automatically when values change. The system discovers dependencies by observing data access, dynamically constructing a dependency graph.
The key features of TRP include:
- declarative: the programmer specifies relationships between values
- transparent: the system (not the programmer) automatically tracks dependencies
- efficient: the system performs only the necessary computations to ensure relationships hold over time
why
TL;DR - TRP is a natural fit for interactive computing but has so far lacked the right interface in popular tools to go mainstream. You can read more of my unfinished thoughts on this topic.
development
this project uses uv for development.
uv run ty check # typecheck code
uv run ruff check # lints code
uv run ruff format # formats code
uv run pytest # run tests
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 signals-0.1.0a6.tar.gz.
File metadata
- Download URL: signals-0.1.0a6.tar.gz
- Upload date:
- Size: 126.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa0c625204dd6f3f867063d735d1b2587f7dc6ef5dbd1193de17175542dd7877
|
|
| MD5 |
d6e5d70190ae5818138705a3d6cc4cd6
|
|
| BLAKE2b-256 |
7a27fddcb71f9e9c4875f59707e945fcc250490b3c80236ff7b8092647b78664
|
Provenance
The following attestation bundles were made for signals-0.1.0a6.tar.gz:
Publisher:
release.yml on manzt/signals
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
signals-0.1.0a6.tar.gz -
Subject digest:
aa0c625204dd6f3f867063d735d1b2587f7dc6ef5dbd1193de17175542dd7877 - Sigstore transparency entry: 1206246205
- Sigstore integration time:
-
Permalink:
manzt/signals@f544803c3535dc1ebd4f399c1ebe9461d6762d1e -
Branch / Tag:
refs/tags/v0.1.0a6 - Owner: https://github.com/manzt
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f544803c3535dc1ebd4f399c1ebe9461d6762d1e -
Trigger Event:
push
-
Statement type:
File details
Details for the file signals-0.1.0a6-py3-none-any.whl.
File metadata
- Download URL: signals-0.1.0a6-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46e72d0ea0f03ea286e19031ceb25d6c2ac2cea84cae6f2270f6abdc6d931353
|
|
| MD5 |
e20c0eb014237c536260d1d98d81ffc1
|
|
| BLAKE2b-256 |
a0a8676cccc4e5f38c38760264ad1fd0e77cae8043dfa16f2876dca7f869bbcd
|
Provenance
The following attestation bundles were made for signals-0.1.0a6-py3-none-any.whl:
Publisher:
release.yml on manzt/signals
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
signals-0.1.0a6-py3-none-any.whl -
Subject digest:
46e72d0ea0f03ea286e19031ceb25d6c2ac2cea84cae6f2270f6abdc6d931353 - Sigstore transparency entry: 1206246216
- Sigstore integration time:
-
Permalink:
manzt/signals@f544803c3535dc1ebd4f399c1ebe9461d6762d1e -
Branch / Tag:
refs/tags/v0.1.0a6 - Owner: https://github.com/manzt
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f544803c3535dc1ebd4f399c1ebe9461d6762d1e -
Trigger Event:
push
-
Statement type: