import hashlib


def sha1sum(filename, buf=65536):
    """Calculate the SHA-1 checksum of a file using a specific buffer
    size so as to avoid placing the whole file into RAM.

    Args:
        filename: The file to calculate the checksum of
        buf: The buffer size to use in bytes (default: 65536)

    Returns:
        The corresponding SHA-1 checksum
    """

    sha1 = hashlib.sha1()
    with open(filename, 'rb') as f:
        while True:
            data = f.read(buf)
            if not data:
                break
            sha1.update(data)
    return sha1.hexdigest()