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.6.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef44fcb974057e3047c8f7f7de97baa71527e465010e4f7911db14747ed610ff |
|
MD5 | fcaf302a24ac38a6308808b0eea25785 |
|
BLAKE2b-256 | 9032d5bd2ccc97ba379f402df0cbcc67d28e02c75dfc8ed3bbea753320098f61 |
Hashes for psygnal-0.6.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a63ce2134aaf67059066889ec9ff9fe03e1919669096a8e8b210621fabb3313a |
|
MD5 | 46124ff1e9c16c5fe24ec36e24bd26dc |
|
BLAKE2b-256 | 1a6f97a4959749dcd65d7e9b270b6e471e1d4e8792f0413977b70d5e794aeb7a |
Hashes for psygnal-0.6.0-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e290c82f8971a60d3243cefdc818fe6bb4493668fb43d80933ee28a34579f9eb |
|
MD5 | d55e7e3bb27622df4b9bd6c6ace6617c |
|
BLAKE2b-256 | aa61256087a89ac57725c74f3ee38cfcecbfdab297753e7fb17ccf06700b8988 |
Hashes for psygnal-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ade1cfad6974fa3033758a146d064d2c92182cc2d305efd8207bb1535a0270b9 |
|
MD5 | 2bfccc446def60eb71781fc4d66a119a |
|
BLAKE2b-256 | ecf96492797ddb47c21a42fbcc369d440352d52c23730febeafec54de8b8a8f6 |
Hashes for psygnal-0.6.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 474b0445b0875126a52d98827ea97b7432c07753a1eedc02e5aaffd51d953569 |
|
MD5 | 790eb6a227edd2fd3d1ab22176b0e034 |
|
BLAKE2b-256 | d27f41253d8ef85f1d886a8068a297d99abd51befdae7565bfec25f1422d8dd3 |
Hashes for psygnal-0.6.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa7ed0c39474b4a9b3440bd699c5e623e7c720cfeea879a17f0b5f619f902a29 |
|
MD5 | 9763bc944bcf801f9e0c374579eb4393 |
|
BLAKE2b-256 | d6262331284b62bae58da921392f24048fcccccccec9244600f75c2509e164f6 |
Hashes for psygnal-0.6.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 811d55095e1f2a27969b0671491ac34ec5ad6d07b05279c2b09af4f6d8445cef |
|
MD5 | e5790beb3d83fcddc3570390c4e03afc |
|
BLAKE2b-256 | 2b8efe8118417fe64b9a681b809a7e2513cb3f56fb565ce9d01be16206db3354 |
Hashes for psygnal-0.6.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4684db6da760182c95d451f3a3a08d36d6f41074e86c04e41fd3193fbbdec398 |
|
MD5 | 7b75b26cf3d4f24d7def81c3d8bec5f8 |
|
BLAKE2b-256 | 05b7ea2740b442d14ce4845a96c6b509f1c53a57057eb24f306825d86764fe20 |
Hashes for psygnal-0.6.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6e6cdf5ec26005480b7be3cacc380e880682999d74d976b25dcb5c3512b59af |
|
MD5 | c1a59078d0644b7601e56565a1fbf0ed |
|
BLAKE2b-256 | 69670781fb95103a515d9c9668677bb96d348d9ca76429f8ea0da2e3cfbcdd87 |
Hashes for psygnal-0.6.0-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c15810a1763c946181b3d6a06086d594f0c8f80f1ff3777584d7c1cd012cd8a3 |
|
MD5 | dfe28ed40ad897aa65da423a11b0f96f |
|
BLAKE2b-256 | c4ec1927b86e9c6174569f0996b5aec53aec467203da15fbab8fb52ae5d2a311 |
Hashes for psygnal-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d7940da6bc20468859d835a1d32210c55fb839f91e0fadaf14b2ba00a4c73be |
|
MD5 | b57bf9bbdf9a6fe96e0fa666f8bdf5b8 |
|
BLAKE2b-256 | ec48e84da87bb7d630e0b2ed4e56885c04050403cf3f1b240367fc6b434ff6d5 |
Hashes for psygnal-0.6.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 916c69b550d3a973e4a8b3ae945d27d16adfe8b743545c6d774586cb5c5dd6c9 |
|
MD5 | cb9fe8e49e50e44bfe3cba9ada614de7 |
|
BLAKE2b-256 | 47b6bbf554ae74cdac7e8cf99134f8fe0f925d28e7a05504232a12c046f06ad1 |
Hashes for psygnal-0.6.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e272a0a108ef9d18999296442435b4b21d716c6a819ce37eee440dc842051cc8 |
|
MD5 | f6cfacb4a969178541a91c0dee8d28e5 |
|
BLAKE2b-256 | 809497f813c20c3f00647ded25124ab96092c0848d9d1a833720fad9657734a0 |
Hashes for psygnal-0.6.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6145b5b8525e17593d3c8dfa152eb5dfd2d614778bda59d56c94b7127e3fbcd |
|
MD5 | da10f723d60a8f9f10693c00acd3470f |
|
BLAKE2b-256 | 1b4ec14d2a4e5314a112a2cfb1110d7a7d381911dc31a811dbf09e9ba7944fbb |
Hashes for psygnal-0.6.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0caad3efde90bf2da9cb9074c6eac99da79ed9e3c9336c3e672006c476f9c11c |
|
MD5 | d06d054f4eead32acce32c81b78d35f1 |
|
BLAKE2b-256 | 50db4863819f86d9f1eefb20f275cc6314f10b4f3af4468f2fd8f72e2d240807 |
Hashes for psygnal-0.6.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aec9ac4a458a39eabcbc89d73c0cdd8896a6f4892186b5bf5002c3ef61cbb771 |
|
MD5 | c4bcdc9d7c2260255417b6334ab2819d |
|
BLAKE2b-256 | fec4474ff3f2df6d7c46bf5f6cbb3736262273affbfcf9e9188dc136e0f52f65 |
Hashes for psygnal-0.6.0-cp38-cp38-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00609916da2ae85bd47e5e231235fc385bf431124754d7c31ddfc7e68ab99afe |
|
MD5 | dcb73d1ee85bcea1785a73717891f3d9 |
|
BLAKE2b-256 | 242dc1ec75993fa792a83a91c8125a9a2e4e84145ec7eaaaacdec848ebc5651c |
Hashes for psygnal-0.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c90623c6b67907a8f3fe629e39236d25e0cb10998df532a2a90d6d67fff75ba |
|
MD5 | c386f25e0cd41e8588599305c7e22901 |
|
BLAKE2b-256 | 573e86a2bde0c3a97d545f1fd1423d719ef6e1ce28603db7566997a7060b1d6e |
Hashes for psygnal-0.6.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3701b4d4b454ed19fb3c01a95cc215d90a204b2026b5f27b972a7d17fd247737 |
|
MD5 | b679a756aa06682210449b54bdaad0d7 |
|
BLAKE2b-256 | 9fdae297ca793d93b4ddfeec2abb24e5b2b51a10f23a8e942a5c0e37543255d7 |
Hashes for psygnal-0.6.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb3896203073ee6bb1e89bc011469a28090bf27ea5163f461d7024cc224a0182 |
|
MD5 | 58a70cc039bac3e2499b41d1b521bd1a |
|
BLAKE2b-256 | 89c95865ed4e7a40b150953c83fca6e2e935f68bb129e89106e93538b6cd4ea6 |
Hashes for psygnal-0.6.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0fc41216f0f109794ac16c1de749613452d8accc657d8029778ba2697072a6d |
|
MD5 | e1d0cf1167327b75e70a3125f60d5e2a |
|
BLAKE2b-256 | babb341cf7f03d3d4db54b3b43ff31f82881142b50bb498db37363273010d22e |
Hashes for psygnal-0.6.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6cb7aedcdb35836b810d2f0396a7005c24a441b4fb97640cafd93a20797b9d6 |
|
MD5 | 877c8c919d7e708bbe9e7f1fb0f9b058 |
|
BLAKE2b-256 | 0df3be2ee06d3ca2f8b9e5ca8e32112fb7dafe7887550b88f3a19bddf0961072 |
Hashes for psygnal-0.6.0-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 161cbb41a32e5ead8f2558165ec45061dc76638799926a21e044b09c98b397a5 |
|
MD5 | 7f1fe9b8af6751ff8cad154f29bad33a |
|
BLAKE2b-256 | 1578988a94b5add3b75c26b6c32d1cea7d78af4e98b4eef4ba71d03b32607bc8 |
Hashes for psygnal-0.6.0-cp37-cp37m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7887044c55be1b542a0fab56ce98ace0814e3e8440d22f979a77c4e61b4bff9a |
|
MD5 | f3a0a058247fa4412f81609d3b0af7f7 |
|
BLAKE2b-256 | bd68077e0e3a287d140f304a21f760e9deaca9a0d3580b10374a756ed56d0266 |
Hashes for psygnal-0.6.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90352a127372cd42c7c275d09b479b4308244cb14ac53c7512f6786bdc27f237 |
|
MD5 | d9465adcd5789fbdeab6f4ec58ad1953 |
|
BLAKE2b-256 | 5b0232b208eb5baa2d2da54a9c1bcb2fb2b97af9cefaecdc81b483cae9218bce |
Hashes for psygnal-0.6.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e65ff84f8c620a86554e0859100ea86084a04438ba20484bd428510ccdd7e5a7 |
|
MD5 | 91e4914ffeea0490624ecb1aafea48c7 |
|
BLAKE2b-256 | 6899d8b8944377ca05743d2b0507219e499a617d909127d14b58da6ab0f25d4e |
Hashes for psygnal-0.6.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cab1ac3e91d51b51b3b04e21c37c6c223454cd49a3d38ed88c95c1c04a0b929a |
|
MD5 | bcdd9a5823e00a90c146c5cf6a0ce8df |
|
BLAKE2b-256 | d2807ba8f72e5d2e0f11b866ec47a3ad221642e88619d4f53d816bf7210e7a49 |