From c57524a3efe3f26bfc7aee7ca80bf6640b23cd02 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 21 Apr 2010 13:38:48 +0200 Subject: apt/cache.py: Make Cache.get_changes() much (~35x) faster (Closes: #578074). This change consists of the following ideas: - Switch to the low-level API - Use 'not marked_keep()' to check if a package has been modified. --- apt/cache.py | 12 ++++++++---- debian/changelog | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apt/cache.py b/apt/cache.py index cfe6bedc..3b0c5f7e 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -176,10 +176,14 @@ class Cache(object): def get_changes(self): """ Get the marked changes """ changes = [] - for pkg in self: - if (pkg.marked_upgrade or pkg.marked_install or pkg.marked_delete - or pkg.marked_downgrade or pkg.marked_reinstall): - changes.append(pkg) + marked_keep = self._depcache.marked_keep + for pkg in self._cache.packages: + if not marked_keep(pkg): + try: + changes.append(self._weakref[pkg.name]) + except KeyError: + package = self._weakref[pkg.name] = Package(self, pkg) + changes.append(package) return changes @deprecated_args diff --git a/debian/changelog b/debian/changelog index 377e7e05..0b02662f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ python-apt (0.7.94.3) UNRELEASED; urgency=low [ Julian Andres Klode ] + * apt/cache.py: + - Make Cache.get_changes() much (~35x) faster (Closes: #578074). * apt/package.py: - Decode using utf-8 in installed_files (LP: #407953). - Fix fetch_source() to work when source name = binary name (LP: #552400). -- cgit v1.2.3