Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

signals-0.1.0a6.tar.gz (126.9 kB view details)

Uploaded Source

Built Distribution

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

signals-0.1.0a6-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

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

Hashes for signals-0.1.0a6.tar.gz
Algorithm Hash digest
SHA256 aa0c625204dd6f3f867063d735d1b2587f7dc6ef5dbd1193de17175542dd7877
MD5 d6e5d70190ae5818138705a3d6cc4cd6
BLAKE2b-256 7a27fddcb71f9e9c4875f59707e945fcc250490b3c80236ff7b8092647b78664

See more details on using hashes here.

Provenance

The following attestation bundles were made for signals-0.1.0a6.tar.gz:

Publisher: release.yml on manzt/signals

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

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

Hashes for signals-0.1.0a6-py3-none-any.whl
Algorithm Hash digest
SHA256 46e72d0ea0f03ea286e19031ceb25d6c2ac2cea84cae6f2270f6abdc6d931353
MD5 e20c0eb014237c536260d1d98d81ffc1
BLAKE2b-256 a0a8676cccc4e5f38c38760264ad1fd0e77cae8043dfa16f2876dca7f869bbcd

See more details on using hashes here.

Provenance

The following attestation bundles were made for signals-0.1.0a6-py3-none-any.whl:

Publisher: release.yml on manzt/signals

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