import hashlib
with open("file5GB.bin" , 'rb') as fd:
md5 = hashlib.md5()
while True:
data = fd.read(2**20)
if not data:
break
md5.update(data)
md5_local = md5.hexdigest()
print md5_local
结果为MemoryError: Exception of type 'System.OutOfMemoryException' was thrown.
相同的代码适用于python。
Ironpython版本:2.7.5,FileSize:5GB