summaryrefslogtreecommitdiff
path: root/apt/cache.py
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-06-21 20:41:36 +0200
committerJulian Andres Klode <jak@debian.org>2009-06-21 20:41:36 +0200
commit99f4e7d2ae98c2f5297d681f1ee89b845b577be0 (patch)
treed1962150333270acdb31efafd3b4d83fe5768128 /apt/cache.py
parentd19176793f57ab8e5882928acd9fb79398e3ac6b (diff)
downloadpython-apt-99f4e7d2ae98c2f5297d681f1ee89b845b577be0.tar.gz
apt/cache.py: Only create _weakrefs, _set once per object.
Diffstat (limited to 'apt/cache.py')
-rw-r--r--apt/cache.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/apt/cache.py b/apt/cache.py
index 949de6cc..737061ad 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -50,6 +50,8 @@ class Cache(object):
def __init__(self, progress=None, rootdir=None, memonly=False):
self._callbacks = {}
+ self._weakref = weakref.WeakValueDictionary()
+ self._set = set()
if memonly:
# force apt to build its caches in memory
apt_pkg.config.set("Dir::Cache::pkgcache", "")
@@ -71,7 +73,7 @@ class Cache(object):
for callback in self._callbacks[name]:
callback()
- def open(self, progress):
+ def open(self, progress=None):
""" Open the package cache, after that it can be used like
a dictionary
"""
@@ -83,8 +85,8 @@ class Cache(object):
self._records = apt_pkg.PackageRecords(self._cache)
self._list = apt_pkg.SourceList()
self._list.read_main_list()
- self._set = set()
- self._weakref = weakref.WeakValueDictionary()
+ self._set.clear()
+ self._weakref.clear()
progress.Op = "Building data structures"
i=last=0