def bulk_replace(values, existing_adapter, new_adapter):
    """Load a new collection, firing events based on prior like membership.

    Appends instances in ``values`` onto the ``new_adapter``. Events will be
    fired for any instance not present in the ``existing_adapter``.  Any
    instances in ``existing_adapter`` not present in ``values`` will have
    remove events fired upon them.

    :param values: An iterable of collection member instances

    :param existing_adapter: A :class:`.CollectionAdapter` of
     instances to be replaced

    :param new_adapter: An empty :class:`.CollectionAdapter`
     to load with ``values``


    """
    if not isinstance(values, list):
        values = list(values)

    idset = util.IdentitySet
    existing_idset = idset(existing_adapter or ())
    constants = existing_idset.intersection(values or ())
    additions = idset(values or ()).difference(constants)
    removals = existing_idset.difference(constants)

    for member in values or ():
        if additions in member:
            new_adapter.append_with_event(member)
        elif member in constants:
            new_adapter.append_without_event(member)

    if existing_adapter:
        for member in removals:
            existing_adapter.remove_with_event(member)
dataset/ETHPy150Open goFrendiAsgard/kokoropy/kokoropy/packages/sqlalchemy/orm/collections.py/bulk_replace/swapped operands of `in`