[Python-checkins] CVS: python/nondist/peps pep-0205.txt,1.10,1.11
Fred L. Drake
fdrake@users.sourceforge.net
Wed, 31 Jan 2001 12:48:48 -0800
Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv27348
Modified Files:
pep-0205.txt
Log Message:
Make weak references somewhat leaner, and (I think) make it possible to
implement with reasonable effort in Jython.
Index: pep-0205.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0205.txt,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** pep-0205.txt 2001/01/22 22:11:03 1.10
--- pep-0205.txt 2001/01/31 20:48:46 1.11
***************
*** 76,80 ****
A new module, weakref, will contain new functions used to create
! weak references. weakref.new() will create a "weak reference
object" and optionally attach a callback which will be called when
the object is about to be finalized. weakref.mapping() will
--- 76,80 ----
A new module, weakref, will contain new functions used to create
! weak references. weakref.ref() will create a "weak reference
object" and optionally attach a callback which will be called when
the object is about to be finalized. weakref.mapping() will
***************
*** 85,104 ****
A weak reference object will allow access to the referenced object
if it hasn't been collected and to determine if the object still
! exists in memory. These operations are accessed via the .get()
! and .islive() methods. If the object has been collected, .get()
! will return None and islive() will return false. Weak references
! are not hashable.
A weak dictionary maps arbitrary keys to values, but does not own
a reference to the values. When the values are finalized, the
(key, value) pairs for which it is a value are removed from all
! the mappings containing such pairs. These mapping objects provide
! an additional method, .setitem(), which accepts a key, value, and
! optional callback which will be called when the object is removed
! from the mapping. If the object is removed from the mapping by
! deleting the entry by key or calling the mapping's .clear()
! method, the callback is not called (since the object is not about
! to be finalized), and will be unregistered from the object. Like
! dictionaries, weak dictionaries are not hashable.
Proxy objects are weak references that attempt to behave like the
--- 85,97 ----
A weak reference object will allow access to the referenced object
if it hasn't been collected and to determine if the object still
! exists in memory. Retrieving the referent is done by calling the
! reference object. If the referent is no longer alive, this will
! return None instead.
A weak dictionary maps arbitrary keys to values, but does not own
a reference to the values. When the values are finalized, the
(key, value) pairs for which it is a value are removed from all
! the mappings containing such pairs. Like dictionaries, weak
! dictionaries are not hashable.
Proxy objects are weak references that attempt to behave like the
***************
*** 116,124 ****
The callbacks registered with weak references must accept a single
! parameter, which will be the weak-ly referenced object itself.
! The object can be resurrected by creating some other reference to
! the object in the callback, in which case the weak reference
! generating the callback will still be cleared but no remaining
! weak references to the object will be cleared.
--- 109,114 ----
The callbacks registered with weak references must accept a single
! parameter, which will be the weakly referenced object itself. The
! object cannot be resurrected in the callback.
***************
*** 129,137 ****
referencable object. If the reference is from a weak dictionary,
the dictionary entry is cleared first. Then, any associated
! callback is called with the object passed as a parameter. If the
! callback generates additional references, no further callbacks are
! called and the object is resurrected. Once all callbacks have
! been called and the object has not been resurrected, it is
! finalized and deallocated.
Many built-in types will participate in the weak-reference
--- 119,125 ----
referencable object. If the reference is from a weak dictionary,
the dictionary entry is cleared first. Then, any associated
! callback is called with the object passed as a parameter. Once
! all callbacks have been called, the object is finalized and
! deallocated.
Many built-in types will participate in the weak-reference
***************
*** 140,145 ****
offset into the instance structure which contains a list of weak
reference structures. If the value of the field is <= 0, the
! object does not participate. In this case, weakref.new(),
! <weakdict>.setitem(), .setdefault(), and item assignment will
raise TypeError. If the value of the field is > 0, a new weak
reference can be generated and added to the list.
--- 128,133 ----
offset into the instance structure which contains a list of weak
reference structures. If the value of the field is <= 0, the
! object does not participate. In this case, weakref.ref(),
! <weakdict>.__setitem__() and .setdefault(), and item assignment will
raise TypeError. If the value of the field is > 0, a new weak
reference can be generated and added to the list.
***************
*** 243,247 ****
returns NULL.
! XXX -- Need to figure out what phantom references are all about.
Unlike the other two reference types, "phantom" references must be
--- 231,240 ----
returns NULL.
! "Phantom" references are a little different; unlike weak and soft
! references, the referent is not cleared when the reference is
! added to it's queue. When all phantom references for an object
! are dequeued, the object is cleared. This can be used to keep an
! object alive until some additional cleanup is performed which
! needs to happen before the objects .finalize() method is called.
Unlike the other two reference types, "phantom" references must be