TimedDict
Requirements
Installation
Package is uploaded on PyPI.
You can install it with pip:
$ python3 -m pip install TimedDict
Backwards compatibility
Backwards compatibility is only guaranteed between minor versions above the stable version (1.0) Therefore it’s advised to to pin the module on a version ether the specific version like: TimedDict==X.X.X
or get the latest minor version: TimedDict~=X.X.X
See more examples of how to pin version in PEP-440.
Documentation
For support, please refer to StackOverflow.
Example
The following example showcases
import time
from TimedDict import timeddict
events_window = timeddict.TimedDict()
now = time.time()
# Assign values like a normal dict like:
events_window[now] = 'value_1'
events_window[now + 1] = 'value_2'
# ...or like:
events_window.update({now + 2: {'values': {'value_3', 'value_4'}}})
print('Raw data:')
print(events_window)
# NOTE:
# As the TimedDict has a thread running purging old elements, it's important to ether
# use the protect() or pause() followed by a resume() when iterating.
# Automatic by the use of context manager, protect() approach
with events_window.protect():
print('\n- protect()')
for event in events_window:
print(event)
# Manual setting, pause() and resume() approach
events_window.pause()
print('\n- pause() followed by resume()')
for event in events_window:
print(event)
events_window.resume()
# TTL example
print('\nLength of the TimedDict: {}'.format(len(events_window)))
print(events_window)
time.sleep(1.1)
print(events_window)
time.sleep(1)
print(events_window)
time.sleep(1)
print(events_window)
# Gracefully stop the purge thread
events_window.stop()
This example will print:
Raw data:
{1534608053.6948583: 'value_1', 1534608054.6948583: 'value_2', 1534608055.6948583: {'values': {'value_4', 'value_3'}}}
- protect()
1534608053.6948583
1534608054.6948583
1534608055.6948583
- pause() followed by resume()
1534608053.6948583
1534608054.6948583
1534608055.6948583
Length of the TimedDict: 3
{1534608053.6948583: 'value_1', 1534608054.6948583: 'value_2', 1534608055.6948583: {'values': {'value_4', 'value_3'}}}
{1534608054.6948583: 'value_2', 1534608055.6948583: {'values': {'value_4', 'value_3'}}}
{1534608055.6948583: {'values': {'value_4', 'value_3'}}}
{}
License
TimedDict is released under the MIT License. See LICENSE for more information.
Metadata
Release files for TimedDict 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| TimedDict-0.2.4.tar.gz | 4.2 kB | Without provenance | Details for TimedDict-0.2.4.tar.gz |
Release files / TimedDict-0.2.4.tar.gz
| Download URL | TimedDict-0.2.4.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b3cadf03b9690d6d96114d8c1ca4168915ca04812c3a8df303567fdee0ca7ed1
|
|
BLAKE2b-256 checksum How to use checksums |
bd4f908d8f51a6d6dc7c3793f965f6b9efe8529ec0c41888b0fffe1a058ea4dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3
|
Security for TimedDict 0.2.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.