from datetime import timedelta SAME = b"0" DIFF = b"1" COMPLEN = len(SAME) # SAME/DIFF length LOCAL_FADVISE = 1 REMOTE_FADVISE = 2 if callable(getattr(os, "posix_fadvise", False)): from os import posix_fadvise, POSIX_FADV_NOREUSE, POSIX_FADV_DONTNEED fadvise = lambda fileobj, offset, length, advice: posix_fadvise(fileobj.fileno(), offset, length, advice) else: try: from fadvise import set_advice, POSIX_FADV_NOREUSE, POSIX_FADV_DONTNEED fadvise = lambda fileobj, offset, length, advice: set_advice(fileobj, advice, offset, length) except: fadvise = None if fadvise: USE_DONTNEED = sys.platform.startswith('linux') USE_NOREUSE = not(USE_DONTNEED) else: USE_NOREUSE = USE_DONTNEED = False def do_create(f, size): f = open(f, 'a', 0) f.truncate(size) f.close()