Skip to content

Instantly share code, notes, and snippets.

View hrchu's full-sized avatar
:octocat:
Have an Octotastic day!

petertc hrchu

:octocat:
Have an Octotastic day!
View GitHub Profile
@hrchu
hrchu / gist:c964f18d60b44f0bb9af
Last active August 29, 2015 14:08
Emulate large file in python, with file-like object interface and without memory overload
file_size=5*2**30 #5GB
class FakeFile:
def __init__(self):
self.remain_size=file_size
def read(self, size):
if self.remain_size == 0:
return None
elif self.remain_size >= size:
self.remain_size-=size