projects
/
mw2txt.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8a43783
)
Adjust mkogg.py's file hash algorithm for faster binary file hashing.
author
W. Trevor King
<wking@drexel.edu>
Wed, 17 Nov 2010 22:13:24 +0000
(17:13 -0500)
committer
W. Trevor King
<wking@drexel.edu>
Wed, 17 Nov 2010 22:13:24 +0000
(17:13 -0500)
posts/mkogg/mkogg.py
patch
|
blob
|
history
diff --git
a/posts/mkogg/mkogg.py
b/posts/mkogg/mkogg.py
index dd8c9f656008608402b8f6a09db3dfdc4ed1e1a6..22d7720eb297fed88b28d6832f5d6c58dcf838a2 100755
(executable)
--- a/
posts/mkogg/mkogg.py
+++ b/
posts/mkogg/mkogg.py
@@
-185,10
+185,13
@@
class Converter (object):
>>> c.cleanup()
"""
h = _hash()
+ chunk_size = 2**20 # 1 Mb
try:
- with open(filename, 'r') as f:
- for line in f:
- h.update(line)
+ with open(filename, 'rb') as f:
+ chunk = ' '
+ while len(chunk) > 0:
+ chunk = f.read(chunk_size)
+ h.update(chunk)
except IOError:
return None
return str(h.hexdigest())