mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Committing the patch in issue 2965, so that weakref dicts have a closer
interface to normal dictionaries. keys(), values() and items() still return iterators instead of views, but that can be fixed later (or not).
This commit is contained in:
parent
6ecc5c1980
commit
ecaab837b6
3 changed files with 23 additions and 57 deletions
|
@ -152,14 +152,9 @@ references that will cause the garbage collector to keep the keys around longer
|
|||
than needed.
|
||||
|
||||
|
||||
.. method:: WeakKeyDictionary.iterkeyrefs()
|
||||
|
||||
Return an :term:`iterator` that yields the weak references to the keys.
|
||||
|
||||
|
||||
.. method:: WeakKeyDictionary.keyrefs()
|
||||
|
||||
Return a list of weak references to the keys.
|
||||
Return an :term:`iterator` that yields the weak references to the keys.
|
||||
|
||||
|
||||
.. class:: WeakValueDictionary([dict])
|
||||
|
@ -176,18 +171,13 @@ than needed.
|
|||
magic" (as a side effect of garbage collection).
|
||||
|
||||
:class:`WeakValueDictionary` objects have the following additional methods.
|
||||
These method have the same issues as the :meth:`iterkeyrefs` and :meth:`keyrefs`
|
||||
methods of :class:`WeakKeyDictionary` objects.
|
||||
|
||||
|
||||
.. method:: WeakValueDictionary.itervaluerefs()
|
||||
|
||||
Return an :term:`iterator` that yields the weak references to the values.
|
||||
These method have the same issues as the and :meth:`keyrefs` method of
|
||||
:class:`WeakKeyDictionary` objects.
|
||||
|
||||
|
||||
.. method:: WeakValueDictionary.valuerefs()
|
||||
|
||||
Return a list of weak references to the values.
|
||||
Return an :term:`iterator` that yields the weak references to the values.
|
||||
|
||||
|
||||
.. class:: WeakSet([elements])
|
||||
|
@ -290,7 +280,7 @@ the referent is accessed::
|
|||
def __init__(self, ob, callback=None, **annotations):
|
||||
super(ExtendedRef, self).__init__(ob, callback)
|
||||
self.__counter = 0
|
||||
for k, v in annotations.iteritems():
|
||||
for k, v in annotations.items():
|
||||
setattr(self, k, v)
|
||||
|
||||
def __call__(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue