Rev 4440: Pre-allocating self._nodes turned out to be slower. in http://bazaar.launchpad.net/~jameinel/bzr/jam-gdfo-heads
John Arbash Meinel
john at arbash-meinel.com
Fri Jun 19 21:08:29 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr/jam-gdfo-heads
------------------------------------------------------------
revno: 4440
revision-id: john at arbash-meinel.com-20090619200803-0s181hhkbo4sf9mh
parent: john at arbash-meinel.com-20090619195441-svubgww09wvmqh40
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: jam-gdfo-heads
timestamp: Fri 2009-06-19 15:08:03 -0500
message:
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