diff options
| author | Julian Andres Klode <jak@debian.org> | 2010-04-21 13:38:48 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2010-04-21 13:38:48 +0200 |
| commit | c57524a3efe3f26bfc7aee7ca80bf6640b23cd02 (patch) | |
| tree | 9cd4c8cff323add4063869f1bf94fd65ddcc258a | |
| parent | 17b0dc6856855f2cd46d234357f0de584db2019e (diff) | |
| download | python-apt-c57524a3efe3f26bfc7aee7ca80bf6640b23cd02.tar.gz | |
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.
| -rw-r--r-- | apt/cache.py | 12 | ||||
| -rw-r--r-- | 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). |
