Code

gitview: Define __slots__ for Commit
authorMichael Ellerman <michael@ellerman.id.au>
Wed, 30 May 2007 04:47:09 +0000 (14:47 +1000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 8 Jun 2007 09:37:18 +0000 (02:37 -0700)
Define __slots__ for the Commit class. This reserves space in each Commit
object for only the defined variables. On my system this reduces heap usage
when viewing a kernel repo by 12% ~= 55868 KB.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/gitview/gitview

index 7e1d68d1677ec91aedbb0305febd9a37c7d87d68..098cb01353d4adbfd32bdd4f70183b4b474f2158 100755 (executable)
@@ -263,6 +263,9 @@ class Commit(object):
        """ This represent a commit object obtained after parsing the git-rev-list
        output """
 
+       __slots__ = ['children_sha1', 'message', 'author', 'date', 'committer',
+                                'commit_date', 'commit_sha1', 'parent_sha1']
+
        children_sha1 = {}
 
        def __init__(self, commit_lines):