Bug#578074: python-apt: apt.cache.Cache.get_changes could be faster
Currently the get_changes call requires to create several thounsands high
level apt.package.Package instances just to check which changes are
marked.
Reply-To: Sebastian Heinlein <devel@glatzor.de>, 578074@bugs.debian.org
Resent-From: Sebastian Heinlein <devel@glatzor.de>
Resent-To: debian-bugs-dist@lists.debian.org
Resent-CC: devel@glatzor.de, APT Development Team <deity@lists.debian.org>
X-Loop: owner@bugs.debian.org
Resent-Date: Fri, 16 Apr 2010 15:39:01 +0000
Resent-Message-ID: <handler.578074.B.127143222132494@bugs.debian.org>
Resent-Sender: owner@bugs.debian.org
X-Debian-PR-Message: report 578074
X-Debian-PR-Package: python-apt
X-Debian-PR-Keywords: patch
X-Debian-PR-Source: python-apt
Received: via spool by submit@bugs.debian.org id=B.127143222132494
(code B ref -1); Fri, 16 Apr 2010 15:39:01 +0000
Received: (at submit) by bugs.debian.org; 16 Apr 2010 15:37:01 +0000
X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02
(2008-06-10) on busoni.debian.org
X-Spam-Level:
X-Spam-Bayes: score:0.0000 Tokens: new, 30; hammy, 151; neutral, 147; spammy,
0. spammytokens: hammytokens:0.000-+--H*M:reportbug, 0.000-+--H*MI:reportbug,
0.000-+--H*x:reportbug, 0.000-+--H*UA:reportbug, 0.000-+--object-o
X-Spam-Status: No, score=-13.1 required=4.0 tests=BAYES_00,FOURLA,HAS_PACKAGE,
MURPHY_DRUGS_REL8,RCVD_IN_PBL,RCVD_IN_SORBS_DUL,XMAILER_REPORTBUG,
X_DEBBUGS_CC autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02
Received: from p5499bfd4.dip.t-dialin.net ([84.153.191.212] helo=klapprechner.daheim)
by busoni.debian.org with esmtp (Exim 4.69)
(envelope-from <devel@glatzor.de>)
id 1O2nbH-0008Qb-Ql
for submit@bugs.debian.org; Fri, 16 Apr 2010 15:37:01 +0000
Content-Type: multipart/mixed; boundary="===============1042741777=="
MIME-Version: 1.0
From: Sebastian Heinlein <devel@glatzor.de>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Message-ID: <20100416153650.9259.21485.reportbug@klapprechner.daheim>
X-Mailer: reportbug 4.12
Date: Fri, 16 Apr 2010 17:36:50 +0200
Delivered-To: submit@bugs.debian.org
This is a multi-part MIME message sent by reportbug.
--===============1042741777==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Package: python-apt
Version: 0.7.94.2
Severity: wishlist
Tags: patch
See the attached patch for a speed up.
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.32-trunk-686 (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages python-apt depends on:
ii apt [libapt-pkg-libc6.9-6-4.8 0.7.25.3 Advanced front-end for dpkg
ii apt-utils [libapt-inst-libc6. 0.7.25.3 APT utility programs
ii libc6 2.10.2-6 Embedded GNU C Library: Shared lib
ii libgcc1 1:4.4.3-7 GCC support library
ii libstdc++6 4.4.3-7 The GNU Standard C++ Library v3
ii python 2.5.4-9 An interactive high-level object-o
ii python-central 0.6.16 register and build utility for Pyt
Versions of packages python-apt recommends:
ii iso-codes 3.15-1 ISO language, territory, currency,
ii lsb-release 3.2-23 Linux Standard Base version report
ii python2.6 2.6.5-1 An interactive high-level object-o
Versions of packages python-apt suggests:
ii python-apt-dbg 0.7.94.2 Python interface to libapt-pkg (de
pn python-apt-doc <none> (no description available)
ii python-gtk2 2.17.0-2 Python bindings for the GTK+ widge
ii python-vte 1:0.24.0-2 Python bindings for the VTE widget
-- no debconf information
--===============1042741777==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="speed-up-get-changes.patch"
=== modified file 'apt/cache.py'
--- apt/cache.py 2010-03-23 12:32:21 +0000
+++ apt/cache.py 2010-04-16 15:25:52 +0000
@@ -176,10 +176,14 @@
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)
+ for pkg_name in self._set:
+ cand = self._cache[pkg_name]
+ if (self._depcache.marked_install(cand) or \
+ self._depcache.marked_delete(cand) or \
+ self._depcache.marked_upgrade(cand) or \
+ self._depcache.marked_downgrade(cand) or \
+ self._depcache.marked_reinstall(cand)):
+ changes.append(self[pkg_name])
return changes
@deprecated_args
--===============1042741777==--
Reply to: