Pyobjects/Set Symmetric Difference
Everything that's in exactly one of two sets
- py_set_a
- py_set_b
- SET
Set Symmetric Difference (SetSymDifferenceNode) is the least commonly reached-for of the LogicUtils set operations, but the one time you need it, nothing else does the job as cleanly: it returns everything that's in exactly one of the two sets, and drops anything in both. Think of it as "the parts that don't match" - the inverse of intersection.
Part of aria1th's ComfyUI-LogicUtils, a personal utility pack from the same GitHub handle behind the Illustrious XL training work. It's a small, quiet pack with almost no discussion online, but the set-algebra family it ships (Create, Add, Remove, Clear, Union, Intersection, Difference, Symmetric Difference, Set to List) mirrors Python's built-in set faithfully, operation for operation.
How it works
It's py_set_a ^ py_set_b, Python's symmetric-difference operator - equivalent to (A - B) | (B - A). Unlike plain difference, this one is symmetric: swapping A and B gives you the same result. It's genuinely useful for diffing two sets against each other when you care about disagreement in either direction - comparing two runs' tag sets to spot everything that changed (added or removed), or checking two "seen" sets built on different branches of a graph to find where they diverged.
If you only care about what's new in one specific set relative to another (not both directions), you want plain Set Difference instead - symmetric difference deliberately throws away the "which side did this come from" information, since both directions get merged into one output set.
Inputs and outputs
py_set_a(SET, required) - the first set.py_set_b(SET, required) - the second set.- Output:
SET- items in exactly one of the two sets (never both).
How to install it
ComfyUI Manager: search "ComfyUI-LogicUtils", install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/aria1th/ComfyUI-LogicUtils
then restart ComfyUI. Pure CPU Python - no models, no VRAM cost.
Common issues & troubleshooting
"Missing node type" on a workflow. ComfyUI Manager's "Install Missing Custom Nodes" resolves the whole pack from the graph JSON.
Import error on startup. The README's auto-installer for the pack's own dependencies is opt-in: set COMFYUI_LOGICUTILS_AUTO_INSTALL=1 before launch if a node needs something not already installed, or COMFYUI_LOGICUTILS_SKIP_INSTALL=1 to disable the hook if it's causing trouble. SetSymDifferenceNode has no external dependency of its own - an import error is a symptom from elsewhere in the pack.
"I wanted only what's new in A, not both directions" and the result has too much in it. That's the difference between symmetric difference and plain difference - if you need a one-directional comparison, swap in Set Difference instead; this node always merges both directions.
Can't connect the output to a non-LogicUtils node. SET is specific to this pack. Run it through Set to List first to get a plain LIST.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| py_set_a | SET | — | |
| py_set_b | SET | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| SET | SET | — |