Skip to main content

Utility functions around state changes.

Latest release 20240214: Initial PyPI release.

Function delta(old, new, keys=None)

Return a mapping representing differences between the mappings old and new for the specified keys. If keys is not specified, the union of the keys of old and new is used.

The returned mapping has a key for each changed value. If the key does not exist in new the value is the MISSING sentinel object otherwise it is new[key]. Values are compared using ==; if that raises TypeError the values are considered not equal.

Example:

d1 = {1: 2, 3: 4, 5: 6} d2 = {1: 2, 3: 44, 7: 8} diff = delta(d1, d2) diff # doctest: +ELLIPSIS {3: 44, 5: <object object at ...>, 7: 8} diff[5] is MISSING True

Function monitor(get_state, keys=None, *, ifunchanged=False, interval=0.3, runstate=None)

A generator yielding 3-tuples of (old,new,delta(old,new,keys)) at poll intervals of interval seconds.

Parameters:

  • get_state: a callable which polls the current state, returning a mapping
  • keys: an optional iterable of keys of interest; if omitted, all the old and new mapping keys are examined
  • ifunchanged: optional flag, default False; if true yield a tuple on every poll instead of only when a state change is seen
  • interval: an optional interpoll time.sleep period, default 0.3s
  • runstate: an optional RunState, whose cancelled attribute will be polled for loop termination

Release Log

Release 20240214: Initial PyPI release.

Release files for cs.delta 20240214

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cs.delta 20240214
File Size Uploaded
cs.delta-20240214.tar.gz 3.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cs.delta 20240214
File Interpreter ABI Platform
cs.delta-20240214-py3-none-any.whl Python 3 none any Details

Total release size: 6.7 kB

Release files / cs.delta-20240214.tar.gz

Download URL cs.delta-20240214.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2cb62057b6b10bd180de15f9863cf6faee6da1b7d7c05a8a85f26d833cda277e
BLAKE2b-256 checksum
How to use checksums
6cdc4cc7ba5bf47baf647d102dec602a13221728e647ea8624789ef34c83c483
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Release files / cs.delta-20240214-py3-none-any.whl

Download URL cs.delta-20240214-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c7ccb3fdae2750be01ceac1aa88ff966ba3d5960cc5104a09f7ccd81cb11f493
BLAKE2b-256 checksum
How to use checksums
33ab0c77e3a5418124a70a8bfe5004a817e38378384fda04e8c0d8ee134450ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Release history Release notifications | RSS feed

This release

20240214 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page