This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: weakref should have a WeakSet
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: leorochael, rhettinger
Priority: normal Keywords:

Created on 2004-07-06 06:42 by leorochael, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg21424 - (view) Author: Leonardo Rochael Almeida (leorochael) Date: 2004-07-06 06:42
It'd be nice if weakref had a WeakSet. This way I
wouldn't need a WeakValueDictionary keyed by id(object)
when all I want is to iterate over the objects that are
still alive.
msg21425 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-07-06 14:09
Logged In: YES 
user_id=80475

Why not use a WeakKeyDictionary with the values set to True?
msg21426 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-07-10 23:58
Logged In: YES 
user_id=80475

Closing this as won't fix.

The WeakKeyDictionary and fromkeys() method meet this need
easily:

alive = WeakKeyDictionary.fromkeys(*objlist)
  . . .
print list(alive)    # always current list of alive objects
History
Date User Action Args
2022-04-11 14:56:05adminsetgithub: 40514
2004-07-06 06:42:00leorochaelcreate