Skip to main content

Fast python callback/event system modeled after Qt Signals

Project description

psygnal

License PyPI Conda Python Version CI codecov Documentation Status

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://pyapp-kit.github.io/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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

psygnal-0.7.0.tar.gz (61.9 kB view details)

Uploaded Source

Built Distributions

psygnal-0.7.0-py3-none-any.whl (48.8 kB view details)

Uploaded Python 3

psygnal-0.7.0-cp311-cp311-win_amd64.whl (199.8 kB view details)

Uploaded CPython 3.11 Windows x86-64

psygnal-0.7.0-cp311-cp311-musllinux_1_1_x86_64.whl (393.2 kB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

psygnal-0.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (414.0 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

psygnal-0.7.0-cp310-cp310-win_amd64.whl (195.5 kB view details)

Uploaded CPython 3.10 Windows x86-64

psygnal-0.7.0-cp310-cp310-musllinux_1_1_x86_64.whl (395.7 kB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

psygnal-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (413.9 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

psygnal-0.7.0-cp39-cp39-win_amd64.whl (195.3 kB view details)

Uploaded CPython 3.9 Windows x86-64

psygnal-0.7.0-cp39-cp39-musllinux_1_1_x86_64.whl (392.4 kB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

psygnal-0.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (411.8 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

psygnal-0.7.0-cp38-cp38-win_amd64.whl (192.2 kB view details)

Uploaded CPython 3.8 Windows x86-64

psygnal-0.7.0-cp38-cp38-musllinux_1_1_x86_64.whl (390.3 kB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

psygnal-0.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (394.6 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

psygnal-0.7.0-cp37-cp37m-win_amd64.whl (186.2 kB view details)

Uploaded CPython 3.7m Windows x86-64

psygnal-0.7.0-cp37-cp37m-musllinux_1_1_x86_64.whl (315.0 kB view details)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

psygnal-0.7.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (319.6 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

File details

Details for the file psygnal-0.7.0.tar.gz.

File metadata

  • Download URL: psygnal-0.7.0.tar.gz
  • Upload date:
  • Size: 61.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for psygnal-0.7.0.tar.gz
Algorithm Hash digest
SHA256 0963f77508126d35dcf7ce3933d0fde5b8e01230360bcf0ce1306eb40eb32e28
MD5 9a178e8fd974edd8356439cf3a311c11
BLAKE2b-256 2e7ae42526ad1d7ba62a7c29d314a5c8681983bd6438203a08f1472e03cc7e09

See more details on using hashes here.

Provenance

File details

Details for the file psygnal-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: psygnal-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 48.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for psygnal-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5051c191176ddab80e04e3738814c6f5e4879459df1a085478db809c35f82e97
MD5 9399729fdc16922cad8adcb6f00fa3a5
BLAKE2b-256 5234f8cd1af7fc3a7f986dc2a46d45afcd2f3c61802657ef22e036e2c1e317c5

See more details on using hashes here.

Provenance

File details

Details for the file psygnal-0.7.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: psygnal-0.7.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 199.8 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.9

File hashes

Hashes for psygnal-0.7.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8ef86f7c5c808e607333bea1f13c2d733ffcc167ea288103362f3c9e59ba925e
MD5 ae6c50c16c89e40c663110054fa1b190
BLAKE2b-256 4270d9491acc8c05cca2f477259bee1af046883f661ed3a6df9189af01adb3d1

See more details on using hashes here.

Provenance

File details

Details for the file psygnal-0.7.0-cp311-cp311-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for psygnal-0.7.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 979b64bcaa2c9b335e5063622cd6659e6c8f3e3276a8c6c0f13ce9a98fad7af5
MD5 c9b375babb97ec76a2c25b8f43f58599
BLAKE2b-256 8b2e7552bb4ce66fc78e2a6b86affc2e4fd1c40d124aa136ae1931aa8680729e

See more details on using hashes here.

Provenance

File details

Details for the file psygnal-0.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for psygnal-0.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1fafd63cc13cd2f7e21979508ddcd999e4d41609b0f0466bd843450c7424d4a9
MD5 3762da44be441cd1ca9e0a23eb3dbac5
BLAKE2b-256 ea3a2800288a6184a0d010d0e19fa32d35897a6c2f892776aedba6209d6cf52a

See more details on using hashes here.

Provenance

File details

Details for the file psygnal-0.7.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: psygnal-0.7.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 195.5 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.9

File hashes

Hashes for psygnal-0.7.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b34f3c0db07d8f67ed0b81223752e7b18f71f98152f68fc3f6ab5fbb0b8315cc
MD5 30eca8147bfbf1c77d390f36b4ab0361
BLAKE2b-256 42118eeacbe5f140183a70557ff1e76cbb15e945c21ebeba0df9e78a29b04c5e

See more details on using hashes here.

Provenance

File details

Details for the file psygnal-0.7.0-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for psygnal-0.7.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 00699009d84b066b486fe0c5b4c88b679019e610fb8f9b8d4607228b47f2fbe9
MD5 35227a1c9aa1de78323bf23faa47b718
BLAKE2b-256 7f7286eab954aa51aab10d25ae2a8961970f89da40a26c4b17da358f66ae2312

See more details on using hashes here.

Provenance

File details

Details for the file psygnal-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for psygnal-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c1b3cbce7e8bedb7deb857cb4d63f12647b7257ab210ab91a39dc3f2958b1fb6
MD5 afcdeb3b2129ad7832605699836bbda5
BLAKE2b-256 7637caabe4cf7d13343c783090bc7e63776d1d864820debc7fe3127634dfb98e

See more details on using hashes here.

Provenance

File details

Details for the file psygnal-0.7.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: psygnal-0.7.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 195.3 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.9

File hashes

Hashes for psygnal-0.7.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3cf0d758e3d4e45dfc70fb49efe272244b5ed5771cd85008643aa9187485570a
MD5 281dabddff2db7f8aa19daf47709c53a
BLAKE2b-256 e2e31c5a8b0c0d64e52079639493932f96cf1267395a7e636118e76b8dec30cd

See more details on using hashes here.

Provenance

File details

Details for the file psygnal-0.7.0-cp39-cp39-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for psygnal-0.7.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 0d1bdb29da1b153a5a46cec2c83f4ab3d2fc643b85bf53e37a4ec91a3fe723a4
MD5 ebbd7ac9a31cefa1623211c8e92ff52a
BLAKE2b-256 80cdabaa96b531a7c3c2134e105ab05837aca6f8304837a63dd249b8eecf973d

See more details on using hashes here.

Provenance

File details

Details for the file psygnal-0.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for psygnal-0.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6764c927f355b7e0c903d93a516b9ef3f70f020ccc716682ff510d7a9fbf12d1
MD5 db6ce748bfa9e81847a07832013d1ae4
BLAKE2b-256 6c610d3dfdd8c6d0f3450a95ac942a9822ca2016095a321aed8124ffbd54653e

See more details on using hashes here.

Provenance

File details

Details for the file psygnal-0.7.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: psygnal-0.7.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 192.2 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.9

File hashes

Hashes for psygnal-0.7.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 cb707f4a35604ba09385eb36a490aac4a54664b5903a4636db219babaf5199c1
MD5 ed9fa61868343ac489f60c66b7a3ffe7
BLAKE2b-256 57adf363dfe24e9f43b117f2f34f4a377b25bcfa3d0b6be61145c6046c6dce09

See more details on using hashes here.

Provenance

File details

Details for the file psygnal-0.7.0-cp38-cp38-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for psygnal-0.7.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 ffbe789459f09334eacd7946c18e64229e0761f2daf39cb19e0cac5cb3bc4566
MD5 9a094f27c5dbdab5d76c6f03bf45667c
BLAKE2b-256 48497afb8f83bce861bf8851b7dbfb97af5b61d5d87652cb25a439a3816451e2

See more details on using hashes here.

Provenance

File details

Details for the file psygnal-0.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for psygnal-0.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e33749df1d97276a70eb70bf2d59e94c33f3f0fb05621f0973040825c34ee9e7
MD5 7e90b2b4a5fd154fe46a60150655e505
BLAKE2b-256 a14848411d03aeb07411ddc8c7cc240f14ce951b32c858a87a26a9e8883413e4

See more details on using hashes here.

Provenance

File details

Details for the file psygnal-0.7.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: psygnal-0.7.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 186.2 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.9

File hashes

Hashes for psygnal-0.7.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 697ed08ecd6425c135085064751d2f189cad48f050618b6af90efcec595308ce
MD5 e1bb670a525441bd095e1c953f2d1c36
BLAKE2b-256 736b87db188767a2aeed8e7b8809f1c46b2cbf1588c9e53fb079e2044738af1a

See more details on using hashes here.

Provenance

File details

Details for the file psygnal-0.7.0-cp37-cp37m-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for psygnal-0.7.0-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 9ecbba027dc911f5f9292bd1d6cefd1511ca6d68fe05ca09b6518d8460afbd57
MD5 441963e1ddebb6b4056cdd5c06d8dc54
BLAKE2b-256 f2eab411363445250eeef6d47dfb8238fda284ad1ab9aa09e05f904765c35e78

See more details on using hashes here.

Provenance

File details

Details for the file psygnal-0.7.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for psygnal-0.7.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 39e002f5fc2724790ed8840fe091b0672dba9bcda9798f4c2ff4e05b0e7b115b
MD5 c24d843940720d3c6e6ba80448226b23
BLAKE2b-256 816b8b5406a53b60822182498928950f63d89890d71277cf6d7b42f64690a27d

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page