Rev 4761: Change CHKMap to use __slots__ in http://bazaar.launchpad.net/~jameinel/bzr/2.1-chk-inv

John Arbash Meinel john at arbash-meinel.com
Tue Oct 20 21:30:35 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/2.1-chk-inv

------------------------------------------------------------
revno: 4761
revision-id: john at arbash-meinel.com-20091020203021-xtusugq202e6qej7
parent: john at arbash-meinel.com-20091020202911-3j1up7554sdwym3u
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1-chk-inv
timestamp: Tue 2009-10-20 15:30:21 -0500
message:
  Change CHKMap to use __slots__
  
  When loading all CHKInventories, this saves 180=>160MB. Each inventory
  has 2 CHKMaps. The leaf nodes and internal nodes result is not specifically
  tested, but I expect a good size savings on real world stuff.
-------------- next part --------------
=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py	2009-10-08 04:35:01 +0000
+++ b/bzrlib/chk_map.py	2009-10-20 20:30:21 +0000
@@ -83,6 +83,8 @@
 class CHKMap(object):
     """A persistent map from string to string backed by a CHK store."""
 
+    __slots__ = ('_store', '_root_node', '_search_key_func')
+
     def __init__(self, store, root_key, search_key_func=None):
         """Create a CHKMap object.
 
@@ -556,6 +558,10 @@
         adding the header bytes, and without prefix compression.
     """
 
+    __slots__ = ('_key', '_len', '_maximum_size', '_key_width',
+                 '_raw_size', '_items', '_search_prefix', '_search_key_func'
+                )
+
     def __init__(self, key_width=1):
         """Create a node.
 
@@ -650,6 +656,8 @@
         the key/value pairs.
     """
 
+    __slots__ = ('_common_serialised_prefix', '_serialise_key')
+
     def __init__(self, search_key_func=None):
         Node.__init__(self)
         # All of the keys in this leaf node share this common prefix
@@ -947,6 +955,8 @@
         LeafNode or InternalNode.
     """
 
+    __slots__ = ('_node_width',)
+
     def __init__(self, prefix='', search_key_func=None):
         Node.__init__(self)
         # The size of an internalnode with default values and no children.



More information about the bazaar-commits mailing list