Pure python callback/event system modeled after Qt Signals
Project description
psygnal
Psygnal (pronounced "signal") is a pure python implementation of Qt-style Signals with (optional) signature and type checking, and support for threading.
Note: this library does not require Qt. It just implements a similar pattern of inter-object communication with loose coupling.
Documentation
https://psygnal.readthedocs.io/
Install
pip install psygnal
conda install -c conda-forge psygnal
Usage
A very simple example:
from psygnal import Signal
class MyObject:
value_changed = Signal(str)
shutting_down = Signal()
my_obj = MyObject()
@my_obj.value_changed.connect
def on_change(new_value: str):
print(f"The value changed to {new_value}!")
my_obj.value_changed.emit('hi')
Much more detail available in the documentation!
Evented Dataclasses
A particularly nice usage of the signal pattern is to emit signals whenever a
field of a dataclass changes. Psygnal provides an @evented
decorator that will
emit a signal whenever a field changes. It is compatible with dataclasses
from the standard library,
as well as attrs, and
pydantic:
from psygnal import evented
from dataclasses import dataclass
@evented
@dataclass
class Person:
name: str
age: int = 0
person = Person('John', age=30)
# connect callbacks
@person.events.age.connect
def _on_age_change(new_age: str):
print(f"Age changed to {new_age}")
person.age = 31 # prints: Age changed to 31
See the dataclass documentation for more details.
Benchmark history
https://www.talleylambert.com/psygnal/
Developers
Debugging
While psygnal
is a pure python module, it is compiled with Cython to increase
performance. To import psygnal
in uncompiled mode, without deleting the
shared library files from the psyngal module, set the environment variable
PSYGNAL_UNCOMPILED
before importing psygnal. The psygnal._compiled
variable
will tell you if you're running the compiled library or not.
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 Distributions
Hashes for psygnal-0.5.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 463330c61496cd326b4637806f415eaf9ad54e3558c81b8b822c8788a3f6ade5 |
|
MD5 | c32c31d7e6d873ac77b711e0dfd92612 |
|
BLAKE2b-256 | 1d21620af806f8956c9c54be2eb55d404e764f17a9ac06e10808fdef6c90fd83 |
Hashes for psygnal-0.5.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a7e983db385704ffbfb150c36a4d48e92971a7afe00a9e4ff6ec90dc72901b9 |
|
MD5 | aeb4ca08f9c0392115fb0ceb6fe11fbf |
|
BLAKE2b-256 | 9a433366901042e8c028f5f1710ccd023e429a118fec3d995de05c4f784d6f9f |
Hashes for psygnal-0.5.0-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 209af516b990b896ff45b25e52de885542b5dca25e1f4f2e8f34dbd3dd2f91b4 |
|
MD5 | d6ac4b8e5568886b3b2048da9287c2ca |
|
BLAKE2b-256 | 028a3bb427402d9d27c0b558ea1b0bb1a589bc2e26323d53659fb4474f8f6f95 |
Hashes for psygnal-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d0345c553bef0e1d85a59bd00e4e595f09cbb0a64a1e07cb2b3881f3fdfe48c |
|
MD5 | 8d633d382539fad0a311f47244fe68a1 |
|
BLAKE2b-256 | 3a59dd131670d615c7d403d6e513000771983b67d98aee99704420d1884786a5 |
Hashes for psygnal-0.5.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59bc898affa63bf93ded5fe0c3117de49301b4b48ab9cca366fef30a4a0ee9a8 |
|
MD5 | 9c749b74b03eb4ded81dd469f076cf83 |
|
BLAKE2b-256 | 37d01588cabd7ac8067cb667f87ffaf3821e632ac8e2612a03aeea369182853f |
Hashes for psygnal-0.5.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b40b05974d7a8dcb9edf0955eb26164a64c74f70004e2b6a8f5d8fc5d64d7e87 |
|
MD5 | b6b73ed4bf94aeb17cec160987d88c08 |
|
BLAKE2b-256 | 55d0922fb0ff19fd6c0f19f253d949d4f554e3fa4f9c50ce389df4f22df709ff |
Hashes for psygnal-0.5.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50d5ac1febdd3635b5ae48d07066cf891e1290063f6f14a16fca5d71e1d85ec8 |
|
MD5 | c327db4992424094ebc59d7d1ff762d4 |
|
BLAKE2b-256 | f17dd2dde00f1e5afac56121d54a1763d71026d8666b79a9e31b8ea87cf654fd |
Hashes for psygnal-0.5.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27a79a3b8b2c217be8d3f8320ae5b8ac0f90fec6104e27fd2513c96ca55ea2d6 |
|
MD5 | 3330f0decec5c2c8e2f9b124e0891ff8 |
|
BLAKE2b-256 | 3cd9f777bf36d0b2d16933a89900a8a57eae473e756ffbde0e5860bb918f3b6a |
Hashes for psygnal-0.5.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16bfc75e22faca79e14300721a03bcaa29eb81d532482be528e6c1b31c002da5 |
|
MD5 | 176343ec92aef64ec12fee3b1a87ad01 |
|
BLAKE2b-256 | d4b1bd830594f9a36d6966524cb50fd6a17ff3a8bd812b2cea97bdeefec3cb79 |
Hashes for psygnal-0.5.0-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a439fd8bddca69eeb1faef716b97690fc015e233f6748f973ba6234e576701e |
|
MD5 | 607649f39dc05cfb023ad763e207272b |
|
BLAKE2b-256 | f71bcf67c0c42ccf9a5427800578f3b7aa7b6b01364eeb2393d2df351e583200 |
Hashes for psygnal-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6394483b400e60f871dbd81dfad0e2ffb58a509dd2194dd02b8cc2086ce5de04 |
|
MD5 | 45290c2c17e59db866f188d7a25f2b9c |
|
BLAKE2b-256 | fddaf19ae48b68d2f8223ec0bdc179f8dac4b1b7c9bee284615d660ffb0a1ebd |
Hashes for psygnal-0.5.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3febace073a393ba2bada6a2f82042554c58453a3b6fd386ac19394908dd4a2c |
|
MD5 | 25aeb529a146f14601077cc37c262c69 |
|
BLAKE2b-256 | 01a1e62d73038312b908088974275cc08ec8d43d5ba0e9850d5cdf36729c4273 |
Hashes for psygnal-0.5.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6566da552f64f8175758520ad06cefd6319a449c44893d5fa2d0de582a8d541 |
|
MD5 | 6cd3fd4f4054a0dee86800b4affd575d |
|
BLAKE2b-256 | edf019abe015e256f723e27a4b68864b01c8e3370be06837a84edfd0a67e6507 |
Hashes for psygnal-0.5.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54ac67982aab504d5045807b37595432f45c3bfee5ad1007ae6d1faa14b25371 |
|
MD5 | 95d64643502015e3d367053cd9ee8b88 |
|
BLAKE2b-256 | 62336833454b3e8c1948726c32243819e78f269deb830ca7b510e10cab4f448f |
Hashes for psygnal-0.5.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8d8316ddbbc2f0de7dddcefc87a344e269053729838af3d340965143a30424c |
|
MD5 | 98879974cc35aa4357cd5897c50a35cb |
|
BLAKE2b-256 | baf8e14a65c3ae5fbd373b3889f13dd2943e7ada451da95d226c2d2966b234d2 |
Hashes for psygnal-0.5.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 432d59e2291e8043d3dac6ee3b29a9d03a1f326052350f812a23346f60a107d2 |
|
MD5 | 374c1a542650be4c01e9e58811c9e497 |
|
BLAKE2b-256 | 2589a20b704cc2d29a9da42dd6c4ff690c5f2bd9a0cd535a4609b36ef53a2e09 |
Hashes for psygnal-0.5.0-cp38-cp38-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3a4939413a657761e0e00751359cff9baea032f1bbbcc1036937e9cc7cc5b07 |
|
MD5 | 8aa943f27bc41727eda2b0368cced45c |
|
BLAKE2b-256 | add8bf365966be908379b46cf7bf6087ced0c7ee30fcb9c4f724b449aab62f83 |
Hashes for psygnal-0.5.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e853b0985d551c403baf835478d823adc67a1dc33d3cb21194e0a3110b28d42 |
|
MD5 | 00b666fa6797afee3087c059c7b2ca55 |
|
BLAKE2b-256 | 96b8d80f664e2105fcaa4e8a866883852d30e0608073f6e57163aaebc7ca0ca9 |
Hashes for psygnal-0.5.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc0da083229ffedf161d964325a2e2873cb039775823734db469b42580b64834 |
|
MD5 | 96b41629448c7279a8730ddbb62ebafb |
|
BLAKE2b-256 | cf26f39ac14cfdff69a53a53ef39fcdf4595731e5092bd79386fd4a16c8f008c |
Hashes for psygnal-0.5.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8e302a33e736f120620b295667580d12ecc773bca255b8b423d56fcee6c8b8d |
|
MD5 | f77ee3c2e989ad35bed7acb5630c2289 |
|
BLAKE2b-256 | 51e6d7a667fd60319d74caefbd57858c96c4cd4c7e597f7790f37cb8214fdb6f |
Hashes for psygnal-0.5.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56091127b8443225f0a8dfccca7ced67d72c65dee4a722501038a7a12a0e4321 |
|
MD5 | 2437d94a720090b8558b0d9acca9226a |
|
BLAKE2b-256 | 45088c122b4dc6ce60bfc355e1cbcca6ca29a33091927ef52277d186feb381fc |
Hashes for psygnal-0.5.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34dd398c61f3b927a05be0dbfa18a2ed36663225af774a0048eb39de2047324c |
|
MD5 | 02e7f957158d69b24991d50baa812a4d |
|
BLAKE2b-256 | e517f73e141c39ecb07f2fa086329c5c069157ec05671d66482bd1c0ecc9374e |
Hashes for psygnal-0.5.0-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27a76ecbed4df20a1b08802b422685170f44437fb70873fdf0d028f1e05912b4 |
|
MD5 | 1d9997d0e6c1fa943023ea41612624c4 |
|
BLAKE2b-256 | 42b746d7971ff83b998894f034aee07e19455b6885713a13a85fdb8e24316b64 |
Hashes for psygnal-0.5.0-cp37-cp37m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab0bb9920301e56113036bfe332feb902ae5ca399c569e4b8afe4b2772d0f8a0 |
|
MD5 | 33bc0554938a2475d7051bb7b0877c45 |
|
BLAKE2b-256 | 8fa76968e602f1fe00d61149a5ce8f94eb890b1c568eaf47bea2a01b635c14ab |
Hashes for psygnal-0.5.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5462dbb377ad08a568fb7230814045d956ead32a1289404b526dcddec5d163e6 |
|
MD5 | 858decbe43fb96292157b3be79a6e798 |
|
BLAKE2b-256 | 901102737b9a8db8eb08f86e5c0eb7ada257153d99bb65ae49a0a374f194a280 |
Hashes for psygnal-0.5.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3473982967c440dc42176454988469182ee1ff4fa6187d550f115c04e10fd99 |
|
MD5 | 43e515c4ebd33f2efe4027bb03f618dc |
|
BLAKE2b-256 | 06201c6b4c81e86e7b0e2e2cf287497b3cfc0036acb4d134fc9fbe90e8edb2d8 |
Hashes for psygnal-0.5.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f717e262a97bd41b110e07c515a3cdf14a5eeeffffc6c5235eaf0a71e7ee338 |
|
MD5 | 1e14bf28eed73c65da0cada80cb0521e |
|
BLAKE2b-256 | b02ad5514f428852700e84ff08600dfb9e2eb7dd5c74d46f5191de0202b61014 |