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.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78f376210b621fa03610318c983944d0e5cdc859905900b7bcf71e280b318758 |
|
MD5 | df35198f0e2c9569daff0073a82f32b0 |
|
BLAKE2b-256 | 0c6b39af12fc943d44909bda81535b90cf7b73337bd067aff24616d1050d20b3 |
Hashes for psygnal-0.4.2-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afd09ad4b9f62f591470ff47102546de03d085aab59408ae8321262ba8b1c01e |
|
MD5 | e152fbe9f8bb172d852707c206282e1d |
|
BLAKE2b-256 | 381bd21324fecc2424818430ccc094e63a587c0bc723e90d449c933418e4bb49 |
Hashes for psygnal-0.4.2-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5206037475f17e71ed2db893044c3b7de0c110d4883b3bcf989824cab01c67fd |
|
MD5 | ae4dcebab1506f39611d215b359ed4d9 |
|
BLAKE2b-256 | 09c532e9e1b80e1af588d0708483b1a40dbdcfe7f4f80cbaed0351e1a590111d |
Hashes for psygnal-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fe0c372058002c7b9309394e160c7c31b119c8bc5fbb6b21bfd8e67540b1cc4 |
|
MD5 | 9901eb425e617373bb5fc249dce9c02f |
|
BLAKE2b-256 | 37dee491cade65c26b953ec4d2570555847e2f6ff118b8373b69a400f653d2ab |
Hashes for psygnal-0.4.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 973e98ce8e0a7aee21c404080437b0e18b097942641699fd32922be580e6c2ec |
|
MD5 | a4bc3455c69fba3b8d82635b3029978e |
|
BLAKE2b-256 | e52f332beffc4857c26474942b336ed8be404421eb464ff1f45335a46ace982a |
Hashes for psygnal-0.4.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60e6e0277e671ecb19c310515528a7e36024dc8a3b0aaf86c652f7f364f45409 |
|
MD5 | 55d8e8aa28614dc462ace617dd50de6f |
|
BLAKE2b-256 | 42af9487985c2821ebc573ee189e090991dad15d432af6b881622b07108195be |
Hashes for psygnal-0.4.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b048180454bbca27fc8d3177addf2b061408663f135b93bc5566d2c33b161c82 |
|
MD5 | 9cc116d8259a7ffc530a3400c923339b |
|
BLAKE2b-256 | f6caad3f370747ec0b88e93817dd24abc3f6b6cbebe365473923db4672e4b104 |
Hashes for psygnal-0.4.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2d290f98922a5c6e99d40144e2851c72acf26f3e6a5ef01f0b2e455a2bbe7f9 |
|
MD5 | 85e182dcd62f7cf8d6d490e440860890 |
|
BLAKE2b-256 | ad17c1fedb9348b5b49da69b09d6a89b2be2242a74f2083e1ffcc683a2702dbd |
Hashes for psygnal-0.4.2-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b83cd4abd26deb0c268519ff7d5c05c32621ef297fb5debdcf846f5e6d23aef |
|
MD5 | c866a24a57dfb79ca8750bb9753df133 |
|
BLAKE2b-256 | 0531ad9b3bd9a094711afdec68fba72f52522410cc99623724d08d9d44532b50 |
Hashes for psygnal-0.4.2-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15830f652106ecd0dd9d4bcaba96c0f798b5bb7f59e0ed8760b9eb971eb6df82 |
|
MD5 | c50440d08debacf8256316d3664afce4 |
|
BLAKE2b-256 | 77d1f531955d78574294b95f6704e39ea279381ecdca074481bc4d611058c1c2 |
Hashes for psygnal-0.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc37c7f01e4e48dcd69972f3eedc7f24ab71535c4be5bd41fe29aa9686c622ec |
|
MD5 | b50c6a62003f6aeecfdda626b15e7993 |
|
BLAKE2b-256 | 73b55fb5eab5f5395a1d851460faa00c3d266a7a592a0976d019dfe58049d6a6 |
Hashes for psygnal-0.4.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 311146f4335a25ddbb008c379d30c938cf247c3e966054022117030f163f51c5 |
|
MD5 | 068cf8e62d7c7997895e81d7cad2a474 |
|
BLAKE2b-256 | 61f7c159eef6bdd6f6ea5294b82e7d2e41829b797cca3472186cf5c0b74ea8d0 |
Hashes for psygnal-0.4.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fca3632b920486036eb9f4f52a20dd409cee57701119fabe666f5ed7ba13a27c |
|
MD5 | 2dc3b72ee7e02b3b2c2aac4dd19ddf1a |
|
BLAKE2b-256 | 3f424f10fb65534321eb1cbecd41ac82b125b1537891a84cbf8f32e6b96047c3 |
Hashes for psygnal-0.4.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b410644f1d99cdad0b35049b6cde2b504a4739cb6dcddc3f6c5e6e9c853deea |
|
MD5 | 984cba8f7251b3da5861652fbb7e8b6b |
|
BLAKE2b-256 | b0acae57798bbbfb90a5ecb658e407666338c1aead7f7f78df26550f77daec51 |
Hashes for psygnal-0.4.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e255c2653c478f81f69731b08012ad0bb3ea81e0d83fe9282fcb7ceb131e146 |
|
MD5 | 5b1cf78ab0101d2eea9870716fa3dc94 |
|
BLAKE2b-256 | 7f4ec278e37ac0e7e44de58ca344acbcf0f39ea66f081936203ef8e370c51159 |
Hashes for psygnal-0.4.2-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2fc45fe226928d5cd76551b7c9624840c66cd85d28c2a5fcdafcf13bc48ff12d |
|
MD5 | 50e1451ad907cf80d60f8133e71c883b |
|
BLAKE2b-256 | 34f0bee900de6309daf9802f9f26acd679759a4401a5887a1b7b4c6ef89a5ce6 |
Hashes for psygnal-0.4.2-cp38-cp38-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4050723613f69227957e5ca346b29802cea615a26d0b22e789e4836ba90f9989 |
|
MD5 | bad8a0c21e13c48a92b2edb9eae475f9 |
|
BLAKE2b-256 | d41354c8fed2340ca9e6e172a0f6ddd26f91c0aa60c589ede26e40de6e2b00c4 |
Hashes for psygnal-0.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ad53efee34f5b815a2abcf58efbf880946363dcbd7a5a54ac1db9c970c65c02 |
|
MD5 | 79dc7149260f8c030315da0df2324486 |
|
BLAKE2b-256 | a76ba8fdca921d1e38970ee3f2335f99c5a9768e2d1d2dbe3b62449d2e604cb2 |
Hashes for psygnal-0.4.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ab2158f096bd83763bbd8066b50a459c9207e9b314f689d1e09f19e27ba6b32 |
|
MD5 | 6f8a462639a5008b191f4a834109f70a |
|
BLAKE2b-256 | 5bb84b8858e431b18af26f23c053c22a2bc3b4bff3eecdb482e39b78feac1fc6 |
Hashes for psygnal-0.4.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b59ed6ea816041eb6cc9e92258ad3b1697b2b6fbca953e2b6cc51e8d5bd514a |
|
MD5 | 1109578aa108c4d3297cc4c5262d955e |
|
BLAKE2b-256 | f2a5f4e3826a1ca3f3a678f5d58b893692c874c4139b5f18dec53c31bff41782 |
Hashes for psygnal-0.4.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1346fb502a883765b4c6003c88481a9b8435496e8a3fa95e3a5300b206624a0e |
|
MD5 | 8f4ace83b47ff1e2ec7b344135d5256b |
|
BLAKE2b-256 | a2bb0474e047bb1a2c90c98ee715ec130d41c8f9881d4b453aa46c3d645d1812 |
Hashes for psygnal-0.4.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8708c76b1bf7ec3f0e45feb3686d6efb9cc01e6ba3c49cf29668c1f0bab3d610 |
|
MD5 | 231c6e079022d56b704a51866adadeb5 |
|
BLAKE2b-256 | 8e25deaec796b28f4871812b90c02ffdc1972d5bf043fb29d6bff99091d6ff68 |
Hashes for psygnal-0.4.2-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0210e54a930391059f21f0d5036512ad2b07afe234e7f912ba50cbab953c5206 |
|
MD5 | 857a3808198191a0434a321a7bb0012f |
|
BLAKE2b-256 | 5930acb533be7cfe08d65086be8d6f374e779628925ee4b2dc15efcafc81665e |
Hashes for psygnal-0.4.2-cp37-cp37m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1d1b8cfd6a38ea3d5e919cdaf38fb51aa01eb57ebbee88b5cc8d5b5d1b9c13f |
|
MD5 | a41d99c6cbe23c8618769f680772dc7a |
|
BLAKE2b-256 | 9a2e8fbec18bddcefc7917d585cb849c63ce4e0b512c8229d060a4934ccd27bd |
Hashes for psygnal-0.4.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfbae2392021400022a4c6032b5ff08e657d909e371f2f39fb575f43e2db1166 |
|
MD5 | 1666a8797d5d1d746fa05e9891759cd9 |
|
BLAKE2b-256 | 85520354cee1eba8e637560ed790d93dd82d5908022c1c48f7b1f204639d3c77 |
Hashes for psygnal-0.4.2-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfb91edfa3a3aca9d5ab45e26560162416438c6e74f309cb1236adcc6915a03a |
|
MD5 | b3d0e29ee1bddd7c519c1e13508422ca |
|
BLAKE2b-256 | a3e3077ccb87b5037662e3160d5efb1b6056eb27cfed1be0ad1b0392add85c1e |
Hashes for psygnal-0.4.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09c920c89f5d41e40057f8dd78546c600f8356f043de062c85404eb331de8c6d |
|
MD5 | d39c3715e2511ff0855b69d94abfa2c0 |
|
BLAKE2b-256 | 1e075cfe59402adba3519ac0f572e3fa44dc57c22d716e35def1293f1af24e25 |