def sizeof_varlen(value):
    """Return number of bytes an integer will need when converted to varlength."""
    if value <= 127:
        return 1
    elif value <= 16383:
        return 2
    elif value <= 2097151:
        return 3
    else:
        return 4