summaryrefslogtreecommitdiff
path: root/lib/git_python/blob.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/git_python/blob.py')
-rw-r--r--lib/git_python/blob.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/git_python/blob.py b/lib/git_python/blob.py
index c89c3c3f..054cdb9b 100644
--- a/lib/git_python/blob.py
+++ b/lib/git_python/blob.py
@@ -23,22 +23,24 @@ class Blob(object):
self.id = None
self.mode = None
self.name = None
- self.size = None
+ self._size = None
self.data_stored = None
self.repo = repo
for k, v in kwargs.items():
setattr(self, k, v)
- def __len__(self):
+ @property
+ def size(self):
"""
The size of this blob in bytes
Returns
int
"""
- self.size = self.size or int(self.repo.git.cat_file(self.id, **{'s': True}).rstrip())
- return self.size
+ if self._size is None:
+ self._size = int(self.repo.git.cat_file(self.id, **{'s': True}).rstrip())
+ return self._size
@property
def data(self):