Skip to main content

Fast, lightweight reactive state for Python

Project description

fastreactpy ⚡

Fast, lightweight reactive state library for Python.

fastreactpy brings React-like reactive state to Python with zero dependencies, minimal overhead, and a clean API.


🚀 Installation

pip install fastreactpy

🧠 Core Concepts

Signal

A signal is a reactive container for state.

from fastreactpy import signal

count = signal(0)
  • count() → get value
  • count(10) → set value and notify subscribers

Effect

An effect automatically re-runs when the signals it uses change.

from fastreactpy import effect

@effect
def logger():
    print("Count:", count())

✨ Basic Example

from fastreactpy import signal, effect

count = signal(0)

@effect
def print_count():
    print("Count changed:", count())

count(5)
count(10)

Output:

Count changed: 0
Count changed: 5
Count changed: 10

📁 Sharing State Between Multiple Files

This is the most common real-world usage.


store.py (Shared State)

from fastreactpy import signal

count = signal(0)
user = signal("Guest")

logger.py (Reactions / Effects)

from fastreactpy import effect
from store import count, user

@effect
def log_count():
    print("[logger] Count:", count())

@effect
def log_user():
    print("[logger] User:", user())

main.py (Mutating State)

import logger  # IMPORTANT: registers effects
from store import count, user

count(1)
user("Malahim")

count(5)
user("Alice")

Output:

[logger] Count: 0
[logger] User: Guest
[logger] Count: 1
[logger] User: Malahim
[logger] Count: 5
[logger] User: Alice

🧩 Multiple Effects on One Signal

from fastreactpy import effect
from store import count

@effect
def double():
    print("Double:", count() * 2)

@effect
def square():
    print("Square:", count() ** 2)

⚡ Why fastreactpy?

  • Zero dependencies
  • Extremely lightweight
  • React-style mental model
  • Automatic dependency tracking
  • Works across files
  • Ideal for CLIs, tools, and services

⚠️ Best Practices

  • Keep shared signals in a single module (e.g. store.py)
  • Always import modules that define effects
  • Avoid heavy logic inside effects
  • Use effects for side-effects only

🌐 Contact

Website: https://malahim.dev

Phone: +92 328 4671797


📄 License

MIT License © 2025 Malahim Haseeb

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

fastreactpy-0.0.2.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

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

fastreactpy-0.0.2-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file fastreactpy-0.0.2.tar.gz.

File metadata

  • Download URL: fastreactpy-0.0.2.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for fastreactpy-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b99e35a9349d5606bdc297bb99e7c820c287ff134c249f3f1083f97c2bdaddb6
MD5 e1f6c13a291849e9faba8bc928762526
BLAKE2b-256 def35af5252014ee6f7d570699c1e056156e796b0b563a50d2a47ebfd6a0a278

See more details on using hashes here.

File details

Details for the file fastreactpy-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: fastreactpy-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for fastreactpy-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dc00c3e2a572d4d1387c2752d80c6af37f056af573a8df43b9259692da30b372
MD5 7a8c4170558f85d45fdff20b7efa582d
BLAKE2b-256 856dd00f6546a75292aa2c4d5a67d1a8ce837d389ad67dda8ae467f4f9e8276a

See more details on using hashes here.

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