[python-debian/jsw/faster-non-shared-storage] 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_bundle/deb822.py |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

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