summaryrefslogtreecommitdiffstats
path: root/Lib/weakref.py
Commit message (Collapse)AuthorAgeFilesLines
* SF #1479988: add methods to allow access to weakrefs for theFred Drake2006-05-021-0/+48
| | | | weakref.WeakKeyDictionary and weakref.WeakValueDictionary
* Bug #1196315: fix weakref.WeakValueDictionary constructor.Georg Brandl2005-06-041-1/+1
|
* Use multi-line importAndrew M. Kuchling2004-08-311-8/+8
|
* SF bug #1012315: weakref.WeakValueDictionary should override .has_key()Raymond Hettinger2004-08-191-31/+36
| | | | | | | | | * Check the found object for a None value during a contains/has_key lookup. Perhaps it will help the OP who is likely suffering from an occassional GC or threading object deletion after self.data is checked. * Complete the previous patch by removing the unnecessary indirection for weak dict iterators. Makes the code cleaner and more readable.
* Convert weak iterators to generator form.Raymond Hettinger2004-08-131-51/+23
|
* Make weak references subclassable:Fred Drake2004-07-021-16/+34
| | | | | | | | | | | | | | | | | | | | | | - weakref.ref and weakref.ReferenceType will become aliases for each other - weakref.ref will be a modern, new-style class with proper __new__ and __init__ methods - weakref.WeakValueDictionary will have a lighter memory footprint, using a new weakref.ref subclass to associate the key with the value, allowing us to have only a single object of overhead for each dictionary entry (currently, there are 3 objects of overhead per entry: a weakref to the value, a weakref to the dictionary, and a function object used as a weakref callback; the weakref to the dictionary could be avoided without this change) - a new macro, PyWeakref_CheckRefExact(), will be added - PyWeakref_CheckRef() will check for subclasses of weakref.ref This closes SF patch #983019.
* The default argument in dict.setdefault() defaults to None.Walter Dörwald2004-05-271-2/+2
| | | | | Add this default to weakref.WeakValueDictionary.setdefault() and weakref.WeakKeyDictionary.setdefault() too.
* SF #904720: dict.update should take a 2-tuple sequence like dict.__init_Raymond Hettinger2004-03-041-6/+16
| | | | | | | | (Championed by Bob Ippolito.) The update() method for mappings now accepts all the same argument forms as the dict() constructor. This includes item lists and/or keyword arguments.
* SF 742860: WeakKeyDictionary __delitem__ uses iterkeysTim Peters2003-05-251-5/+1
| | | | | | | | | | | | | | | | | Someone review this, please! Final releases are getting close, Fred (the weakref guy) won't be around until Tuesday, and the pre-patch code can indeed raise spurious RuntimeErrors in the presence of threads or mutating comparison functions. See the bug report for my confusions: I can't see any reason for why __delitem__ iterated over the keys. The new one-liner implementation is much faster, can't raise RuntimeError, and should be better-behaved in all respects wrt threads. New tests test_weak_keyed_bad_delitem and test_weak_keyed_cascading_deletes fail before this patch. Bugfix candidate for 2.2.3 too, if someone else agrees with this patch.
* SF patch #667730: More DictMixinRaymond Hettinger2003-03-091-0/+15
| | | | | | | | * Adds missing pop() methods to weakref.py * Expands test suite to broaden coverage of objects with a mapping interface. Contributed by Sebastien Keim.
* Whitespace normalization.Tim Peters2002-07-161-1/+1
|
* SF patch 564549 (Erik Andersén).Guido van Rossum2002-06-101-1/+1
| | | | | | | The WeakKeyDictionary constructor didn't work when a dict arg was given. Fixed by moving a line. Also adding a unit test. Bugfix candidate.
* SF 563203. Replaced 'has_key()' with 'in'.Raymond Hettinger2002-06-011-1/+8
|
* WeakKeyDictionary.has_key(): If the key being tested is not weaklyFred Drake2001-11-061-1/+5
| | | | | | referencable (weakref.ref() raises TypeError), return 0 instead of propogating the TypeError. This closes SF bug #478536; bugfix candidate.
* ReferenceError is now built-in, so pick it up from the right place.Fred Drake2001-10-051-1/+3
| | | | It still needs to be here to preserve the API.
* Clean up circular references in the Weak*Dictionary classes; this avoidsFred Drake2001-09-281-11/+14
| | | | | | | | depending on the cycle detector code in the library implementation. This is a *slightly* different patch than SF patch #417795, but takes the same approach. (This version avoids calling the __len__() method of the dict in the remove() functions.) This closes SF patch #417795.
* Add __delitem__() support for WeakKeyDictionary.Fred Drake2001-09-061-0/+7
| | | | This closes SF bug #458860.
* Make sure that WeakValueDictionary[] raises KeyError instead of TypeErrorFred Drake2001-08-031-1/+1
| | | | for keys that are not in the dictionary.
* Added iterator support to the Weak*Dictionary classes.Fred Drake2001-05-021-0/+73
|
* Weak*Dictionary: Added docstrings to the classes.Fred Drake2001-04-191-24/+36
| | | | | | | | | | | | | | | | Weak*Dictionary.update(): No longer create a temporary list to hold the things that will be stuffed into the underlying dictionary. This had been done so that if any of the objects used as the weakly-held value was not weakly-referencable, no updates would take place (TypeError would be raised). With this change, TypeError will still be raised but a partial update could occur. This is more like other .update() implementations. Thoughout, use of the name "ref" as a local variable has been removed. The original use of the name occurred when the function to create a weak reference was called "new"; the overloaded use of the name could be confusing for someone reading the code. "ref" used as a variable name has been replaced with "wr" (for 'weak reference').
* Weak*Dictionary.update(): Fix calls to [].append() to only have oneFred Drake2001-04-161-4/+15
| | | | | | | | parameter. Weak*Dictionary.get(): Make the second parameter optional. WeakKeyDictionary.has_key(), .keys(): Make these actually work!
* mapping(): Remove this function since it does not add anything to the API.Fred Drake2001-04-101-8/+1
|
* final round of __all__ lists (I hope) - skipped urllib2 because Moshe may beSkip Montanaro2001-03-011-0/+3
| | | | giving it a slight facelift
* Change WeakDictionary to WeakValueDictionary in a couple more places.Fred Drake2001-03-011-4/+7
| | | | | WeakValueDictionary.copy(), WeakKeyDictionary.copy(): Actually return the copy!
* Patch #403985: Add support for weak-keyed dictionariesMartin v. Löwis2001-02-271-3/+60
|
* Ouch! I need a better test suite for this. ;-(Fred Drake2001-02-021-1/+0
|
* WeakDictionary.items(): Do not allow (key,ref) pairs to leak out forFred Drake2001-02-021-3/+3
| | | | dead references.
* PEP 205, Weak References -- initial checkin.Fred Drake2001-02-011-0/+117