Rev 4748: Timing 'bzr branch' reveals some code paths that are being strict about type. in http://bazaar.launchpad.net/~jameinel/bzr/2.1-static-tuple

John Arbash Meinel john at arbash-meinel.com
Fri Oct 2 22:55:45 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/2.1-static-tuple

------------------------------------------------------------
revno: 4748
revision-id: john at arbash-meinel.com-20091002215539-lkt3m830jhz49ayi
parent: john at arbash-meinel.com-20091002214612-rq4vb31klg6tqqr2
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1-static-tuple
timestamp: Fri 2009-10-02 16:55:39 -0500
message:
  Timing 'bzr branch' reveals some code paths that are being strict about type.
  Namely, assuming that a key is a tuple, rather than possibly a StaticTuple.
  Shame that it is exposed in such a fashion...
  Anyway, 'bzr branch --no-tree bzr.dev standalone' is:
    407320MB @ 2m4.207s  => 331876MB @ 1m42s
  
  So while 'bzr log' doesn't really show the improvement, it is quite obvious during 'bzr branch'.
-------------- next part --------------
=== modified file 'bzrlib/index.py'
--- a/bzrlib/index.py	2009-08-17 22:11:06 +0000
+++ b/bzrlib/index.py	2009-10-02 21:55:39 +0000
@@ -40,6 +40,7 @@
     debug,
     errors,
     )
+from bzrlib._static_tuple_c import StaticTuple
 
 _HEADER_READV = (0, 200)
 _OPTION_KEY_ELEMENTS = "key_elements="
@@ -102,7 +103,7 @@
 
     def _check_key(self, key):
         """Raise BadIndexKey if key is not a valid key for this index."""
-        if type(key) != tuple:
+        if type(key) not in (tuple, StaticTuple):
             raise errors.BadIndexKey(key)
         if self._key_length != len(key):
             raise errors.BadIndexKey(key)



More information about the bazaar-commits mailing list