Returns if given object is read only ( built-in or extension ).

    :param object: Object.
    :type object: object
    :return: Is object read only.
    :rtype: bool

def is_read_only(object):
    """
    Returns if given object is read only ( built-in or extension ).

    :param object: Object.
    :type object: object
    :return: Is object read only.
    :rtype: bool
    """

    try:
        attribute = "_trace__read__"
        setattr(object, attribute, True)
        delattr(object, attribute)
        return False
    except (TypeError, AttributeError):
        return True