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!
Alternatives
There are other libraries that implement similar event-based signals, they may server your purposes better depending on what you are doing.
PySignal (deprecated)
This package borrows inspiration from – and is most similar to – the now
deprecated PySignal project, with a few
notable new features in psygnal
regarding signature and type checking, sender
querying, and threading.
similarities with PySignal
- still a "Qt-style" signal implementation that doesn't depend on Qt
- supports class methods, functions, lambdas and partials
differences with PySignal
- the class attribute
pysignal.ClassSignal
is called simplySignal
inpsygnal
(to more closely match the PyQt/Pyside syntax). Correspondinglypysignal.Signal
is similar topsygnal.SignalInstance
. - Whereas
PySignal
refrained from doing any signature and/or type checking either at slot-connection time, or at signal emission time,psygnal
offers signature declaration similar to Qt with , for example,Signal(int, int)
. along with opt-in signature compatibility (withcheck_nargs=True
) and type checking (withcheck_types=True
)..connect(..., check_nargs=True)
in particular ensures that any slot to connected to a signal will at least be compatible with the emitted arguments. - You can query the sender in
psygnal
by using theSignal.sender()
orSignal.current_emitter()
class methods. (The former returns the instance emitting the signal, similar to Qt'sQObject.sender()
method, whereas the latter returns the currently emittingSignalInstance
.) - There is basic threading support (calling all slots in another thread), using
emit(..., asynchronous=True)
. This is experimental, and while thread-safety is the goal, it is not guaranteed. - There are no
SignalFactory
classes here.
The following two libraries implement django-inspired signals, they do not attempt to mimic the Qt API.
Blinker
Blinker provides a fast dispatching system that allows any number of interested parties to subscribe to events, or "signals".
SmokeSignal
(This appears to be unmaintained)
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.4.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c374f7abf028a46607c0674f736a6c9b30a98379c99201a6e56303d74dc6df8b |
|
MD5 | a14a6ac1eca360d95760c9fb4351a018 |
|
BLAKE2b-256 | 420b85b334349ec533935bb99ed7bfdbf0c4c8e595946de292dacb7bed4de84b |
Hashes for psygnal-0.4.1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3930944d3fdc4ceb25f9f4a3eb268347ae04b9182e1e0065b298b5d6b70bb30d |
|
MD5 | dbc122e3aae75867735292434456c273 |
|
BLAKE2b-256 | d245fdda4764e8717850b613cffc9d2b15b034a9dcaeb96f9c49a17cc0f43235 |
Hashes for psygnal-0.4.1-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3666b87d91b4f15e346d366c3c733e2ddc33c7d7aeffe82ef98016c8fff24ca2 |
|
MD5 | 8c14d39f54c11244897ffcc7a128c0b3 |
|
BLAKE2b-256 | bee86ceace3f6b20bcf070bec0ae821727175715894341a6d0a79f451acfec01 |
Hashes for psygnal-0.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66b08d7f486bd54c91174685aaf7b0cbbc336baa44ff2f6c25d1dbb98af7979a |
|
MD5 | fe00c9758f31d25888aeba837407f31f |
|
BLAKE2b-256 | c26dadfb354ae85c796a7a29a36cb7370d1147f927b72ccbe663599b26eb4bac |
Hashes for psygnal-0.4.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd4808139f7419b8008dc9e612792ada6bf043bd7133b1a90ee1450af85b147e |
|
MD5 | 803b6f99f63bdfbb27335609b3c1730d |
|
BLAKE2b-256 | 9c51f7325a76b215b3d0b809f5b9d852b5acb7198124e6e8149d726d9f3a6c9e |
Hashes for psygnal-0.4.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c314536a8eb733ac90f77d44721a3cfb0ef1f5fd79b94dc3b12a6aeeff17c451 |
|
MD5 | 30fdcd7f4ff022f5eb9dbb44969cac84 |
|
BLAKE2b-256 | 42c6ca595f9bf51a036646acb97107bb4e0662a23a5fbd29a906fce49958ead8 |
Hashes for psygnal-0.4.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b93575a086affc7dd01a48e6b30774ebac5409c4abbdd246e12cde52e2232624 |
|
MD5 | 13dfec7d216077df159c32bc99e7ae35 |
|
BLAKE2b-256 | f888312c12b1165e8844c820c8f302cb4a17495877bb83cc27d6f4c646b476d1 |
Hashes for psygnal-0.4.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd854a7f793ca5a8df67d8eb188e79782fd65a9c9f0b6be5024684af72b99b88 |
|
MD5 | 2230c2fdfa32abf9c2bcde3fa508b682 |
|
BLAKE2b-256 | 3b34409a3569108129548a4a68f6dbaf92a317fc8297852b53d7cbf35f749a67 |
Hashes for psygnal-0.4.1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a2dcedb563420f22b25112339096b91c660dde97e246ac2275e34efb62b0348 |
|
MD5 | 1393e24bbf8b38cdbc2940f4dd308ebd |
|
BLAKE2b-256 | bdd749073c1e848af11cdf56df866851ae04e12f12f4b94214433a8efcd60cf5 |
Hashes for psygnal-0.4.1-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdcfa9ce8ce57902b99345ae5ce005ee97cff9d391f08d35430a7c47d0669fe6 |
|
MD5 | 4fd3b507adf3afa942893479e951dd89 |
|
BLAKE2b-256 | 255840d25cf238bea6695d6aa2d39e26a324b27bf8ff393406ff17a51bd82bea |
Hashes for psygnal-0.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc145eb298da0c75fa28d21716a1ace71f6ec4dacaea8b71f694036a657f0c24 |
|
MD5 | a0194d36124e5c2fe8248fdf84930f8e |
|
BLAKE2b-256 | 5853bd6450ca1a542f0b5d81ddc79657d473fd436734589630099adea03c9391 |
Hashes for psygnal-0.4.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbce76b4c6bae22d2bbd25f7ddf11a3455eaedc06d5e936c30ce6f89741f61a6 |
|
MD5 | fed7f9e9ec0ded5a6f2c0a99173bfd47 |
|
BLAKE2b-256 | c309f5910511fe6adbe5afbbbbec845c3cb61a19fa71c3f0853526a6406bc807 |
Hashes for psygnal-0.4.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 168d884728169b49a5c5db83cf5921f49a69bb7d97e3b8ef9fab9f5d5530117b |
|
MD5 | 750b25a2a1c556917aa862c6c37c4552 |
|
BLAKE2b-256 | 290dec53b75d965d939942cb6d1b2fbe2fdcb4fb7da25312d21a9f63952e2471 |
Hashes for psygnal-0.4.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc3d7863ed8677151410c8bb1769d3ac8bd4aa8bb0e1ee9444c6f5950ff89595 |
|
MD5 | 233ba92aeb8437ed98596e90e7e7127f |
|
BLAKE2b-256 | e32d35dfd1f02c158dba408fc7e3c98fb258bfaea33d4390d948521b015b19b4 |
Hashes for psygnal-0.4.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | add68e312784cca69b6a98a5ba3077c2d21fb2fc5679d56c758e0a0d094013f6 |
|
MD5 | b60424fee8594c590de94e55b94c1891 |
|
BLAKE2b-256 | 42c1701368ee70ee9cff8aa3bb80a7278294f3858f2aec8272283ea8566985dc |
Hashes for psygnal-0.4.1-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83081ee0aab1105e34f542acf1dbbd57fdb175ae86354a58f634fa6127d8ee0c |
|
MD5 | 1b7f60d58b5be6d4b2d1ffb16ac7f540 |
|
BLAKE2b-256 | 27c2f55684b97af10221f34c641d94bab0fa885b9426eec06defa26ccf996d31 |
Hashes for psygnal-0.4.1-cp38-cp38-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fc794f623ca9a6cac7cdb8487e7fc28b74337951be9c71bec42a933eb0709de |
|
MD5 | 266265a6a7d4673012f2eaf50abb0670 |
|
BLAKE2b-256 | 15a33236f70f792213d88a0a52dd14222d824b6864c58e9dd59974de2877c714 |
Hashes for psygnal-0.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 249944189ab416f510c30c9610550cd867eb26e14b991cf2532c260b8ea0fe4a |
|
MD5 | 6c8995cd1a0b22329dcf8d09c5865308 |
|
BLAKE2b-256 | c7fc0cdcaab3f1e8742a7190e5821f19df2c57494fbebaaf3753b602da7f173a |
Hashes for psygnal-0.4.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcfbae02df10df34a77074edaf99b590495d6b0505037448561745b023dbe540 |
|
MD5 | 2f1baac50b77d392bf26973d9e0532eb |
|
BLAKE2b-256 | 2e1cad39414c15eb55465cd8fe2220b3d024ce5b67fca523a78e5d5b16da360a |
Hashes for psygnal-0.4.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7641efefee96d4db717368aff44e2b9460f2bd5ea0cb0cbcf2e4713c551f2d8e |
|
MD5 | ea6ada6f94f3e57e9dd5c1c8f34fbef0 |
|
BLAKE2b-256 | 40baece05067b7b4aa2c310d0b09bb53e3decd095e23f9c97e6fbe231a967b3f |
Hashes for psygnal-0.4.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96f4d2847450ed08edd9e639e382ebecee204c4b38783cc63a01b7205126012b |
|
MD5 | f9d2833e8dd1375553bd141b7bae7487 |
|
BLAKE2b-256 | 40fb953ae7806edf0aacaf5cdec766b78c5e7455cee725314a2cc99fd658c245 |
Hashes for psygnal-0.4.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47176a93038590475029be81a25c6c2476e36ea2984e382507860a995fe2d645 |
|
MD5 | 8f14763ae001208aff2e79c4d6343f6a |
|
BLAKE2b-256 | c727b6d06482e989984c83f0531c90e0a295ab09ca1fc1a1635db95b89802c77 |
Hashes for psygnal-0.4.1-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92a538d3e1e5ce5ef8d76a1768015994a11231a7409735bf41c2406836023211 |
|
MD5 | d6950d0e931a02e81b2533990b33e0bd |
|
BLAKE2b-256 | b012adcc5abe52b9924e40814dcb05592d30f06d02b91580d9d6503995238b55 |
Hashes for psygnal-0.4.1-cp37-cp37m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8ca07034099330ccecb99d5271b72ba1adf3a9b1bf3b85195300c95d2216f71 |
|
MD5 | b1923570627b59c458c85e4181d4cd60 |
|
BLAKE2b-256 | e3b99c8ff071756068ed601db32d533957b49ef9164c96459752becb8e102e84 |
Hashes for psygnal-0.4.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc221430d9bc4f6437d4202a7716d5cc9813d7d9fb7ffc0b5d8b8763b18ca0a8 |
|
MD5 | 956064870b11aa57f8314e73b6623a2b |
|
BLAKE2b-256 | e2c5a7418c068c8584d516fea52739fe3f880a1bbbad1f69d34bd0b8abf5416c |
Hashes for psygnal-0.4.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 191787ead6cf86f84655c22fa94b86661d6fc3ed3bc0833539ff76806ed9d418 |
|
MD5 | abf027ba03d41f0d6bf0566569df819d |
|
BLAKE2b-256 | 1c1cdb4da253938dc4fcab0f9a077896ebf010b061dfc4cc7baf5c44ff564adf |
Hashes for psygnal-0.4.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61b883f2e0ce3a718bed3db476db4ca5d794ac5426362e7fbb0b0f93cb35576c |
|
MD5 | ff118222172b7d1195f06cda0ab4b9a7 |
|
BLAKE2b-256 | 87fd3c57b29969e8b74e53f89f26da05bc8fbd37317bf1aa65e1699194418daf |