import hashlib


def file_hashes(f, bufsize=16000000):
  """
  computes md5, sha1, sha256 from a file obj.  intended for large files.
  returns 3-tuple of hexstrings
  """
  md5 = hashlib.md5()
  sha1 = hashlib.sha1()
  sha256 = hashlib.sha256()
  while True:
    buf = f.read(bufsize)
    if len(buf) == 0:
      break
    md5.update(buf)
    sha1.update(buf)
    sha256.update(buf)
  return (md5.hexdigest(), sha1.hexdigest(), sha256.hexdigest())