Skip to main content

timedpool

Python library adding a dictionary with a maximum size and whose elements are deleted after a delay.

Installation

Run: pip install timedpool

Usage

TimedPool is a dict with a maximum size whose elements are deleted after a delay.

This object can be used as a dictionary:

p = TimedPool()
p[key] = value
if key in p:
    print(p[key])
print(len(p))
del p[key]

The difference with a normal dictionary is that this can contain a maximum number of objects, after which insertions will raise a FullException. Furthermore, each item can be removed after a certain amount of time (ttl). Items are not removed immediately, but at fixed intervals.

Using p[key] = value will apply the default ttl; instead, p.set(ket, value, ttl) allows to set a specific ttl.

The stop() method can be used to stop the cleaning routine.

Both max_size and clean_t must be greater or equal to 0, negative values are rounded to 0.

The initial parameter can be an iterable of tuples that is used to populate the pool with some elements. It is equivalent to adding each key-value tuple to the pool in the order provided by the iterable. If initial is a dictionary, its elements will be added in the order provided by the dictionary items() method.

This object supports all the methods of a python dict with the following exceptions:

  • copy
  • setdefault
  • update
  • values
  • items

Implementation

The implementation extends a python dict. A routine is run on another thread to periodically scan the elements and remove those that are expired.

This implies that expired elements will be still available until the cleaning routine is run.

Contribute

If you find a bug, have a feature request or suggestions, please open an issue on github.

Metadata

Release files for timedpool 0.1.1

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

Source distribution (sdist)

Source distribution for timedpool 0.1.1
File Size Uploaded Provenance Actions
timedpool-0.1.1.tar.gz 16.0 kB Without provenance Details for timedpool-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for timedpool 0.1.1
File Interpreter ABI Platform Actions
timedpool-0.1.1-py3-none-any.whl Python 3 none any Details for timedpool-0.1.1-py3-none-any.whl

Total release size: 32.8 kB

Release files / timedpool-0.1.1.tar.gz

Download URL timedpool-0.1.1.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3200c3890a80d3bf9f7d75ccf5553c07465a88e166fe3fbc1b553ab3b0c89ca8
BLAKE2b-256 checksum
How to use checksums
bd2346c43a3197d455234d19073ec563a285c2ff1283ac5f8e66ac533fe6f793
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

Release files / timedpool-0.1.1-py3-none-any.whl

Download URL timedpool-0.1.1-py3-none-any.whl
Size 16.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
38e83efe460218ead26e10cffe988db55b6f7c27dca80df7d25d629e789717fd
BLAKE2b-256 checksum
How to use checksums
783efb16882f7f70ba62064f46f433a3dd5a0d06ad2a233de92dfa20b728a611
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

Security for timedpool 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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