def write_length_and_key(fp, value):
    """
    Helper to write descriptor key.
    """
    written = write_fmt(fp, 'I', 0 if value in _TERMS else len(value))
    written += write_bytes(fp, value)
    return written