[Python-ideas] weakref.WeakKeyDictionary is (basically) useless
Kevin Norris
nykevin.norris at gmail.com
Wed Dec 31 19:26:44 CET 2014
More information about the Python-ideas mailing list
Wed Dec 31 19:26:44 CET 2014
- Previous message: [Python-ideas] weakref.WeakKeyDictionary is (basically) useless
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Dec 31, 2014 at 6:00 AM, Antoine Pitrou <solipsis at pitrou.net> wrote: >> Why would you use it? The official documentation mentions >> implementing a [descriptor][1]. See [this paste][2] for a simple >> example of this sort of thing. > > How about something like this (untested): > A cursory glance suggests that might work for my use-case, but I would want to examine it more thoroughly for race conditions and other hazards. In particular, I'd be concerned about the potential performance cost of removing things immediately on finalization (the stdlib implementation uses a semi-lazy approach here, which I still don't entirely understand). I'm also a little nervous about doing anything remotely interesting from a finalizer. With a little fine-tuning, however, this could be pulled into a separate WeakKeyIDDictionary implementation, which would be more modular and easier to work with. -- Kevin Norris
- Previous message: [Python-ideas] weakref.WeakKeyDictionary is (basically) useless
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list