[python-debian/master] deb822: Faster non-shared storage
John Wright
john at johnwright.org
Sun Jul 26 17:06:16 UTC 2009
This involves creating a new TagFile object for each iterated Deb822
object yieled in iter_paragraphs. Normally, this would not be such a
great idea, since all of the TagFile instances will share the same file
object; however, we don't expose the TagFile object itself, so it will
always be locked to a particular stanza in the control file.
---
debian/changelog | 2 ++
debian_bundle/deb822.py | 12 +++++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 781a8f5..748ec97 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,8 @@ python-debian (0.1.15) UNRELEASED; urgency=low
previous implementation added extra newlines when given a file
object as input, rather than the result of str.splitlines().
(Closes: #539316)
+ * deb822: Faster non-shared storage by keeping a TagFile object
+ around for each Deb822 object yielded
-- John Wright <jsw at debian.org> Thu, 30 Jul 2009 01:03:49 +0200
diff --git a/debian_bundle/deb822.py b/debian_bundle/deb822.py
index c1301f1..dd1d201 100644
--- a/debian_bundle/deb822.py
+++ b/debian_bundle/deb822.py
@@ -270,10 +270,16 @@ class Deb822(Deb822Dict):
if _have_apt_pkg and use_apt_pkg and isinstance(sequence, file):
parser = apt_pkg.ParseTagFile(sequence)
while parser.Step() == 1:
- parsed = TagFileWrapper(parser)
+ x = cls(fields=fields, _parsed=TagFileWrapper(parser))
+ if len(x) != 0:
+ yield x
+
if not shared_storage:
- parsed = Deb822Dict(parsed)
- yield cls(fields=fields, _parsed=parsed)
+ # Make a new parser, starting it right before the next
+ # section
+ offset = parser.Offset() - 1
+ parser = apt_pkg.ParseTagFile(sequence)
+ parser.Jump(offset)
else:
iterable = iter(sequence)
--
1.5.6.5
More information about the pkg-python-debian-commits
mailing list