def get_filesize(file):
    """Get file size from file object.
    
    :param file: File object, returned e.g. by :func:`open`.
    :type file: file object
    
    :return: File size in bytes.
    :rtype: int
    
    """
    offset = file.tell()
    file.seek(0, 2)
    filesize = file.tell()
    file.seek(offset)
    return filesize