Use weakref.WeakValueDictionary to make cached Atom instances eligible for
authorZac Medico <zmedico@gentoo.org>
Tue, 24 Jun 2008 22:30:48 +0000 (22:30 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 24 Jun 2008 22:30:48 +0000 (22:30 -0000)
garbage collection when no strong references remain.

svn path=/main/trunk/; revision=10772

pym/portage/dep.py

index 3d3b5d954d1f4e80f325cf37b7a10d6ab18441e8..41d6b128b939429d73e316dcb46e913811a13910 100644 (file)
@@ -19,6 +19,7 @@
 #
 
 import re, sys, types
+import weakref
 from itertools import chain
 import portage.exception
 from portage.exception import InvalidData, InvalidAtom
@@ -412,7 +413,7 @@ class Atom(object):
        """
 
        __metaclass__ = _AtomCache
-       _atoms = {}
+       _atoms = weakref.WeakValueDictionary()
 
        _str_methods = ("endswith", "find", "index", "lstrip", "replace",
                "startswith", "strip", "rindex", "rfind", "rstrip", "__getitem__",