homepage

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: Making weakref.ref subclassable
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: fdrake
Priority: high Keywords: patch

Created on 2004年06月30日 21:04 by fdrake, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
subclassable-weakrefs.patch fdrake, 2004年06月30日 21:04 Patch to make weakref.ref a subclassable new-style type
subclassable-weakref-docs.patch fdrake, 2004年07月02日 16:08 Documentation patch
Messages (3)
msg46285 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2004年06月30日 21:04
This patch makes weak references subclassable. This
includes the following changes:
- 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
- the cyclic garbage detector will be affected by the
change to PyWeakref_CheckRef(); it will potentially
call issubtype() for objects in the unreachable list
that do not have finalizers (in the
move_troublemakers() function). This should only
happen for weakref objects which are not of one of the
"standard" three types (ref, proxy, and callable
proxy). For debug builds, it will also affect
assertions in the clear_weakerfs() and
release_weakrefs() functions.
The change to the cyclic garbage detector probably
carries the most risk, and that only because the
potential for a performance penalty. Running the Zope
3 test suite did not show any clear change in
performance, and a key subsystem in Zope
(zope.interface) uses weakrefs extensively.
msg46286 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2004年07月02日 16:08
Logged In: YES 
user_id=3066
Added LaTeX documentation as a separate patch.
msg46287 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2004年07月02日 19:02
Logged In: YES 
user_id=3066
Committed for Python 2.4:
Doc/lib/libweakref.tex 1.27
Include/weakrefobject.h 1.5
Lib/test/test_weakref.py 1.41
Lib/weakref.py 1.23
Misc/NEWS 1.1020
Modules/_weakref.c 1.19
Objects/object.c 2.219
Objects/weakrefobject.c 1.17
History
Date User Action Args
2022年04月11日 14:56:05adminsetgithub: 40485
2004年06月30日 21:04:51fdrakecreate

AltStyle によって変換されたページ (->オリジナル) /