git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] gitview: Define __slots__ for Commit

From
Michael Ellerman <michael@ellerman.id.au>
Date
May 30, 2007, 04:47 UTC
Message-ID
<f9b34180c9ece0068109ed1021e196150cb81c57.1180500418.git.michael@ellerman.id.au>
In-Reply-To
<f623da83269ba030fabc64777cdb1071e5ab00bf.1180500418.git.michael@ellerman.id.au>

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>
---
 contrib/gitview/gitview |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/contrib/gitview/gitview b/contrib/gitview/gitview
index 6b54bc0..4baa1dd 100755
--- a/contrib/gitview/gitview
+++ b/contrib/gitview/gitview
@@ -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):
-- 
1.5.1.3.g7a33b
Previous: Michael EllermanNext: Junio C Hamano
Message 2 of 4 in “gitview: Use new-style classes”
  1. 1/2 gitview: Use new-style classesMichael Ellerman, May 30, 2007
  2. 2/2 gitview: Define __slots__ for CommitMichael Ellerman, May 30, 2007
  3. Junio C HamanoJun 2, 2007
  4. Michael EllermanJun 4, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.