# -*- coding: utf-8 -*- import io import os import hashlib s = u' '*(256**4//2) #+ u"перфекто" s=s.encode('utf-8') #s=' '*(10) in_digest = hashlib.md5(s).hexdigest() fname = 'outlong.dat' if os.path.exists(fname): os.unlink(fname) with io.FileIO(fname, 'wb') as f: #with open(fname, 'wb') as f: n = f.write(s) #n = os.stat(fname).st_size print("Written %d out of %d" % (n, len(s))) if n != len(s): print("%d bytes were not written" % (len(s) - n)) # checksum with open(fname, 'rb') as f: out_digest = hashlib.md5(f.read()).hexdigest() assert in_digest == out_digest, "Digests do not match" print("all ok")