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 Benchmarks

Psygnal (pronounced "signal") is a pure python implementation of the observer pattern, with the API of Qt-style Signals with (optional) signature and type checking, and support for threading.

This library does not require or use Qt in any way, It simply implements a similar observer pattern API.

Documentation

https://psygnal.readthedocs.io/

Install

pip install psygnal
conda install -c conda-forge psygnal

Usage

The observer pattern is a software design pattern in which an object maintains a list of its dependents ("observers"), and notifies them of any state changes – usually by calling a callback function provided by the observer.

Here is a simple example of using psygnal:

from psygnal import Signal

class MyObject:
    # define one or more signals as class attributes
    value_changed = Signal(str)

# create an instance
my_obj = MyObject()

# You (or others) can connect callbacks to your signals
@my_obj.value_changed.connect
def on_change(new_value: str):
    print(f"The value changed to {new_value}!")

# The object may now emit signals when appropriate,
# (for example in a setter method)
my_obj.value_changed.emit('hi')  # prints "The value changed to 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/

and

https://codspeed.io/pyapp-kit/psygnal

Developers

Debugging

While psygnal is a pure python module, it is compiled with mypyc to increase performance. To disable all compiled files and run the pure python version, you may run:

python -c "import psygnal.utils; psygnal.utils.decompile()"

To return the compiled version, run:

python -c "import psygnal.utils; psygnal.utils.recompile()"

The psygnal._compiled variable will tell you if you're using the compiled version 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.9.4.tar.gz (83.9 kB view details)

Uploaded Source

Built Distributions

psygnal-0.9.4-py3-none-any.whl (71.3 kB view details)

Uploaded Python 3

psygnal-0.9.4-cp311-cp311-win_amd64.whl (310.7 kB view details)

Uploaded CPython 3.11 Windows x86-64

psygnal-0.9.4-cp311-cp311-musllinux_1_1_x86_64.whl (574.5 kB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

psygnal-0.9.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (595.0 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

psygnal-0.9.4-cp311-cp311-macosx_10_16_x86_64.whl (380.5 kB view details)

Uploaded CPython 3.11 macOS 10.16+ x86-64

psygnal-0.9.4-cp311-cp311-macosx_10_16_arm64.whl (355.5 kB view details)

Uploaded CPython 3.11 macOS 10.16+ ARM64

psygnal-0.9.4-cp310-cp310-win_amd64.whl (306.2 kB view details)

Uploaded CPython 3.10 Windows x86-64

psygnal-0.9.4-cp310-cp310-musllinux_1_1_x86_64.whl (582.5 kB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

psygnal-0.9.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (601.6 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

psygnal-0.9.4-cp310-cp310-macosx_10_16_x86_64.whl (384.3 kB view details)

Uploaded CPython 3.10 macOS 10.16+ x86-64

psygnal-0.9.4-cp310-cp310-macosx_10_16_arm64.whl (360.6 kB view details)

Uploaded CPython 3.10 macOS 10.16+ ARM64

psygnal-0.9.4-cp39-cp39-win_amd64.whl (306.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

psygnal-0.9.4-cp39-cp39-musllinux_1_1_x86_64.whl (578.5 kB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

psygnal-0.9.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (599.0 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

psygnal-0.9.4-cp39-cp39-macosx_10_16_x86_64.whl (384.2 kB view details)

Uploaded CPython 3.9 macOS 10.16+ x86-64

psygnal-0.9.4-cp39-cp39-macosx_10_16_arm64.whl (360.5 kB view details)

Uploaded CPython 3.9 macOS 10.16+ ARM64

psygnal-0.9.4-cp38-cp38-win_amd64.whl (301.0 kB view details)

Uploaded CPython 3.8 Windows x86-64

psygnal-0.9.4-cp38-cp38-musllinux_1_1_x86_64.whl (576.0 kB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

psygnal-0.9.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (579.8 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

psygnal-0.9.4-cp38-cp38-macosx_10_16_x86_64.whl (380.7 kB view details)

Uploaded CPython 3.8 macOS 10.16+ x86-64

psygnal-0.9.4-cp38-cp38-macosx_10_16_arm64.whl (356.2 kB view details)

Uploaded CPython 3.8 macOS 10.16+ ARM64

psygnal-0.9.4-cp37-cp37m-win_amd64.whl (293.9 kB view details)

Uploaded CPython 3.7m Windows x86-64

psygnal-0.9.4-cp37-cp37m-musllinux_1_1_x86_64.whl (460.9 kB view details)

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

psygnal-0.9.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (464.6 kB view details)

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

psygnal-0.9.4-cp37-cp37m-macosx_10_16_x86_64.whl (367.2 kB view details)

Uploaded CPython 3.7m macOS 10.16+ x86-64

File details

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

File metadata

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

File hashes

Hashes for psygnal-0.9.4.tar.gz
Algorithm Hash digest
SHA256 26dc485bc86dea509abfb6eff93eb1f44865aa9b61c2ed8ee0fc0d57dde47bda
MD5 bf2105f90dba4da0603e7ea800034148
BLAKE2b-256 8336e86937d4c60107c5e5a0e01369965b5455d37eaf3efad854be7411d2e58b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for psygnal-0.9.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7e696c0680f4ee73ebf0e93bf55f53d948b865b580b8b5ffbf037cd273b2c88b
MD5 cede6dd10c077d0c349c1931dd25403b
BLAKE2b-256 60fbf11642b49d9a20ec571f1227fbf47603d416eb781b4a536d20091432f7ac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: psygnal-0.9.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 310.7 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.9.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8646e39355d4c779d837bcbfd4438084e14c69a6fcc2768ba2d821d29b7670b7
MD5 0145f04bd6bd02ae27b5ede29c665de0
BLAKE2b-256 6732d91f410d42f2eb44f0830f1b2768a237229706e1fdd0b89328461d33a2c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for psygnal-0.9.4-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 c5e3963e35bc8b775e6baeba8c80f95eb451c9b9de00590590bc6a6ecdd4f8b1
MD5 e08889c8162043e333b6de13e958386c
BLAKE2b-256 128535330f430ef8fbbbf2174e113f5a3bd1af3de20569505e90c5e2100a18d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for psygnal-0.9.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 32794689fb208180fee7490e3cc76df65d383b40aa773a4c7120424a6b734965
MD5 9eca1a1161a9be9134a76d436546755a
BLAKE2b-256 61b923493d740bc789f32113788398cee8bc02fb908032415e79d32a7b4bc779

See more details on using hashes here.

File details

Details for the file psygnal-0.9.4-cp311-cp311-macosx_10_16_x86_64.whl.

File metadata

File hashes

Hashes for psygnal-0.9.4-cp311-cp311-macosx_10_16_x86_64.whl
Algorithm Hash digest
SHA256 a193468e5581f9479af59df6fcd44905bfdfc996656f8b087ce0f60982e55e9a
MD5 b13ca75cd82622fe112cc03f00f251fc
BLAKE2b-256 ec8ffc9f9b48b596976d5ba22fa4b8391a155b617707e2f04d70e73769f98215

See more details on using hashes here.

File details

Details for the file psygnal-0.9.4-cp311-cp311-macosx_10_16_arm64.whl.

File metadata

File hashes

Hashes for psygnal-0.9.4-cp311-cp311-macosx_10_16_arm64.whl
Algorithm Hash digest
SHA256 0af6b1dca9a7ef29468a49d1fded8493bf91627f57a5bb02df6e3b3b97f6ba14
MD5 f6fed74f362635d5d371693a6e7f4616
BLAKE2b-256 ed859e3adf0acf6b6f1afa09d604529de32288385fd1682efc36a251deca2dc2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: psygnal-0.9.4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 306.2 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.9.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ca08bc6eaa0f6f5602e28fcb6924ba9dd929c40fe371cb96cc64f29cb0befb6c
MD5 39b4f7726777d6934b4d9fc63139caa8
BLAKE2b-256 0127fa851cf3823f6567d2dd6f002210efbde8eec9c4e9e8372638abed519bac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for psygnal-0.9.4-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 e38575d09eca6a8a7f167d6114cfdac740a3774c32820f9b650a59550afd3327
MD5 f85cbf76b2db32183193313690dbeb8f
BLAKE2b-256 058db8e384fcc22d2ec2a8085e433ca5d3c6501c1606f17dd2b260580928ca04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for psygnal-0.9.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1d0514f553b344a71efe94550ca090fdf06034597a316950770d33620f0f9d47
MD5 63820e636f18d8bd80a838028cfef218
BLAKE2b-256 5a6f8393c5b6d473558542b7099a242854ab1be7561cb8beea734ae4ee10f0f0

See more details on using hashes here.

File details

Details for the file psygnal-0.9.4-cp310-cp310-macosx_10_16_x86_64.whl.

File metadata

File hashes

Hashes for psygnal-0.9.4-cp310-cp310-macosx_10_16_x86_64.whl
Algorithm Hash digest
SHA256 498100d1b5ae83292422965a3637b37dddffde2548afac102de084a2a73a391d
MD5 19b7577355e818f7759d139ac374e627
BLAKE2b-256 b258f0470738c9deebe75b22761e935d7bd453725453b25ef361bb1898266951

See more details on using hashes here.

File details

Details for the file psygnal-0.9.4-cp310-cp310-macosx_10_16_arm64.whl.

File metadata

File hashes

Hashes for psygnal-0.9.4-cp310-cp310-macosx_10_16_arm64.whl
Algorithm Hash digest
SHA256 dbb97204879ac37d3ff0c9afe978582c6e6e10cbf54ae8e9e8ee790d2e59995a
MD5 08744e282197ab91ee1f8bde9b233e57
BLAKE2b-256 e36bc500df37d5cae29b9c4bc480f96b02428768df57bcaa69d1dde30cda3a17

See more details on using hashes here.

File details

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

File metadata

  • Download URL: psygnal-0.9.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 306.0 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.9.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 eedf46cbf9992be271367b7d732ddbded0ef1bdfc3df92ba77f99871f8666de5
MD5 8e4534f06e29b8e3e983a8fea2e92b11
BLAKE2b-256 a64bb9400413c0c0373ee9469adc838c52cdf624219a7a1063e15a3fd6698add

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for psygnal-0.9.4-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 fdf327ab12d97ab556400d28d8446ad6e59890a145719584687670b70813422a
MD5 f8258b2f99eda0f41ad59e973da321c2
BLAKE2b-256 cad902d06ff4725e0150b61a44f63838508b04315ac9fc8016a67adfbcb905a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for psygnal-0.9.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b0d5ce7926e8415cb296c1d267d7bd07e90d250397ae6cff3012b43bcd7dd6e1
MD5 b9f87bcae3e547ca77a4014fe2e3cb95
BLAKE2b-256 546e8ae63560b308ec185e3a35e56f95b9c1c76831eec9a643e88de39d09a6c1

See more details on using hashes here.

File details

Details for the file psygnal-0.9.4-cp39-cp39-macosx_10_16_x86_64.whl.

File metadata

File hashes

Hashes for psygnal-0.9.4-cp39-cp39-macosx_10_16_x86_64.whl
Algorithm Hash digest
SHA256 82e1c5110b474a1d98914ff8f8f3d29df76638924f4ec12769d0c8afb62d3a99
MD5 036ffb2e698e3691ab997018a53284ac
BLAKE2b-256 7d75d132549dfdb6fe8e31c1f93ad4d660d3cf5257a130f9d4fd5a2026728289

See more details on using hashes here.

File details

Details for the file psygnal-0.9.4-cp39-cp39-macosx_10_16_arm64.whl.

File metadata

File hashes

Hashes for psygnal-0.9.4-cp39-cp39-macosx_10_16_arm64.whl
Algorithm Hash digest
SHA256 05018751371ddc8a99a6ab9271f6b6ca7cca1df91637eb5b972d567fe2f8bc2c
MD5 30bb265689fa124f24faf91515ba7e80
BLAKE2b-256 7b0f098802913c8ce4fdfa8e9d3e0249ab313eb941b4922612581df3886a82b5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: psygnal-0.9.4-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 301.0 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.9.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 133ad346d0faeae03642ac422346f9708248ebb370c1461e283b8887e85b5be1
MD5 62f2b12107a25bdf6950d38682146d94
BLAKE2b-256 5f62ceeaf16ee4a1dcaae21c5e92107af136ac4766dfa007262c5f34bea725e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for psygnal-0.9.4-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 f12d7ea15398b9df86f653f1c619a179fac35cd0e6a9084f2f3badc031cf786e
MD5 0777ca34326cab0795c7371684839efc
BLAKE2b-256 9c433e4822d35fd635999faf0d6a45aa52ac2a817f4a7d79d0b7feb70aabd18c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for psygnal-0.9.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d39a6b534ac9c203e3eab88d504e436cd6aace022d438e243570617e2c6f4e69
MD5 adb48bb8893d80b08461a3cac10812fb
BLAKE2b-256 f89b91504687bc14645ecd40d53450fa19afc54f9f10ce920cf68b5582e58819

See more details on using hashes here.

File details

Details for the file psygnal-0.9.4-cp38-cp38-macosx_10_16_x86_64.whl.

File metadata

File hashes

Hashes for psygnal-0.9.4-cp38-cp38-macosx_10_16_x86_64.whl
Algorithm Hash digest
SHA256 bc9f3ebfac147a61f544f4ece782d4a2035cbc74f2471094d57196e165b4004f
MD5 099dc2e661e2f433a321c4d796cc374a
BLAKE2b-256 efb623935eb5ab41fbd9015196ee1e63a9c1c7f0f123fd881ab1be4ee09c9212

See more details on using hashes here.

File details

Details for the file psygnal-0.9.4-cp38-cp38-macosx_10_16_arm64.whl.

File metadata

File hashes

Hashes for psygnal-0.9.4-cp38-cp38-macosx_10_16_arm64.whl
Algorithm Hash digest
SHA256 aad2732760cee6622a53bca542ef2cccb30a270980de99bc882c8302c93531ef
MD5 72b5a7595ef1b7d071dcc077122d0695
BLAKE2b-256 7ad599b067d07e5b55697a96b899babf60fecbb0d2f4578285e394db968cd985

See more details on using hashes here.

File details

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

File metadata

  • Download URL: psygnal-0.9.4-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 293.9 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.9.4-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 c93d800e2e6aefd3022b966188efba9d74e016677c8c0872261dbbbfa5cd4350
MD5 995a10f5b595102f95a182be1639e1c9
BLAKE2b-256 7922fcb45b9f1cbb0bb55c1e3862b2bb2f9e925fc9ef1c2887ab60d4a83cc98e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for psygnal-0.9.4-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 99047badf82d12bfc42aa3b886ca358867e199af6d3b0c6e3be7d406a1f142ff
MD5 e562a1863476bf17a775c16204880857
BLAKE2b-256 37f5eb22f049f42fd5893c992354ede9ce1ad456e8295a6b37fb3cd85d47a102

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for psygnal-0.9.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c4d3237c48d1692d954566a8f3611dc695fbce24786ac49b638c169872d782b7
MD5 9377f98283ccb8bddd785207f27fe3de
BLAKE2b-256 fdcce0e5aca16e950cddb5ca90dddf7a28ef7f9f18be05e53ecd75e1b9f2c69f

See more details on using hashes here.

File details

Details for the file psygnal-0.9.4-cp37-cp37m-macosx_10_16_x86_64.whl.

File metadata

File hashes

Hashes for psygnal-0.9.4-cp37-cp37m-macosx_10_16_x86_64.whl
Algorithm Hash digest
SHA256 b2bdc6cc28816e91b55c39caff332fe8f81cf4ab94b61a3a19c4833ab99b1a9d
MD5 f956135d2c0f01d7fe96f8550ab5f27f
BLAKE2b-256 9b0527c189a6b7a9b794514c19f52a95d5e1f8ae652394c1b54fbe4fa31f1028

See more details on using hashes here.

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