Make the Atom cache dict private and add a docstring for _AtomCache.
authorZac Medico <zmedico@gentoo.org>
Fri, 20 Jun 2008 16:47:45 +0000 (16:47 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 20 Jun 2008 16:47:45 +0000 (16:47 -0000)
svn path=/main/trunk/; revision=10742

pym/portage/dep.py

index a1908276be998d8ae3c59bbfcd8db453f0079f3b..bd9b19677e693e59992d9ae81ad8ceabf04a7499 100644 (file)
@@ -393,12 +393,15 @@ class _use_dep(object):
                return _use_dep(tokens)
 
 class _AtomCache(type):
-       atoms = {}
+       """
+       Cache Atom instances from constructor calls and reuse
+       identical instances when available.
+       """
        def __call__(cls, s):
-               instance = cls.atoms.get(s)
+               instance = cls._atoms.get(s)
                if instance is None:
                        instance = super(_AtomCache, cls).__call__(s)
-                       cls.atoms[s] = instance
+                       cls._atoms[s] = instance
                return instance
 
 class Atom(object):
@@ -409,6 +412,7 @@ class Atom(object):
        """
 
        __metaclass__ = _AtomCache
+       _atoms = {}
 
        _str_methods = ("endswith", "find", "index", "lstrip", "replace",
                "startswith", "strip", "rindex", "rfind", "rstrip", "__getitem__",