Python 2.7 & 3.1 include a WeakSet class, a collection for storing objects using weak references (see the Python weakref module).
This project is a backport of the weakrefset module, and tests, for Python 2.5 and 2.6. The tests require the unittest2 package.
Mercurial repository & issue tracker: http://code.google.com/p/weakrefset/
You can install it with: pip install weakrefset
Usage is straightforward. You don’t need to deal with weak references themselves, the WeakSet manages the references and you can add / remove / iterate over your objects directly:
>>> from weakrefset import WeakSet >>> class Foo(object): pass ... >>> f1 = Foo() >>> f2 = Foo() >>> refs = WeakSet([f1, f2]) >>> f3 = Foo() >>> refs.add(f3) >>> refs.remove(f1) >>> del f2 >>> f3 in refs True >>> for f in refs: ... print f ... <__main__.Foo object at 0x40e410>
To be compatible with Python 2.5, 2.6 and future versions of Python you can import it like this:
try:
# location in Python 2.7 and 3.1
from weakref import WeakSet
except ImportError:
# separately installed
from weakrefset import WeakSet
Metadata
Release files for weakrefset 1.0.0
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 |
|---|---|---|---|---|
| weakrefset-1.0.0.tar.gz | 2.8 kB | Without provenance | Details for weakrefset-1.0.0.tar.gz |
Release files / weakrefset-1.0.0.tar.gz
| Download URL | weakrefset-1.0.0.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1199c768153c2f4ac123f2a57e93a28185d843b09864ea3f4219d383d1cc16aa
|
|
BLAKE2b-256 checksum How to use checksums |
d2cd8c62dab782ac0abcacaff31a3c5919eb8cd42b6936ab70b0d8a0a221ec5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for weakrefset 1.0.0
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.