[Python-Dev] r84727 - in python/branches/py3k: Lib/collections.py Misc/NEWS (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Sun Sep 12 12:38:24 CEST 2010
- Previous message: [Python-Dev] [Python-checkins] r84619 - python/branches/py3k/Misc/developers.txt
- Next message: [Python-Dev] r84744 - python/branches/py3k/Objects/unicodeobject.c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, 12 Sep 2010 06:12:42 +0200 (CEST) raymond.hettinger <python-checkins at python.org> wrote:
- # Each link is stored as a list of length three: [PREV, NEXT, KEY]. + # The back links are weakref proxies (to prevent circular references).
Are you sure this prevents anything? Since your list is circular, forward links are enough to build a reference cycle.
Actually, this is exemplified here:
_+ self.root = root = Link() # sentinel node for the doubly linked list + root.prev = root.next = root
root.next = root
is enough to create a cycle, even if you make
root.prev a weakref.
What you need is to make both prev and next weakrefs. All list nodes all held by the __map dict anyway.
If you are bothered about speed, an alternative would be a classic finalization scheme, using a class-wide set of OrderedDict weakrefs that remove themselves and clean up the doubly-linked list when the OrderedDict becomes dead.
- Previous message: [Python-Dev] [Python-checkins] r84619 - python/branches/py3k/Misc/developers.txt
- Next message: [Python-Dev] r84744 - python/branches/py3k/Objects/unicodeobject.c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]