Rev 4440: Pre-allocating self._nodes turned out to be slower. in

John Arbash Meinel john at
Fri Jun 19 21:08:29 BST 2009


revno: 4440
revision-id: john at
parent: john at
committer: John Arbash Meinel <john at>
branch nick: jam-gdfo-heads
timestamp: Fri 2009-06-19 15:08:03 -0500
  Pre-allocating self._nodes turned out to be slower.
  I guess it doesn't realloc very often, and save on dict lookups while it is small.
  Also, you don't end up with the incref/decref to None, but I would imagine that is
  a trivial amount of time.
  I wish it was easier to define an allocator for Pyrex objects. (It is fairly easy
  in the Python C api.)
-------------- next part --------------
=== modified file 'bzrlib/_known_graph_pyx.pyx'
--- a/bzrlib/_known_graph_pyx.pyx	2009-06-19 19:54:41 +0000
+++ b/bzrlib/_known_graph_pyx.pyx	2009-06-19 20:08:03 +0000
@@ -134,6 +134,7 @@
         :param parent_map: A dictionary mapping key => parent_keys
+        # tests at pre-allocating the node dict actually slowed things down
         self._nodes = {}
         # Maps {sorted(revision_id, revision_id): heads}
         self._known_heads = {}

More information about the bazaar-commits mailing list