Nodes/ComfyUI-LogicUtils/Pyobjects/Set Difference
ComfyUI Node

Pyobjects/Set Difference

What's in A that isn't in B

By aria1th·Created 3 years ago·Updated 7 months ago· 116
Pyobjects/Set Difference
  • py_set_a
  • py_set_b
  • SET

Set Difference (SetDifferenceNode) answers one specific question: what's in set A that isn't also in set B? Order matters here - unlike union or intersection, difference isn't symmetric. A - B and B - A are usually different sets, so which input you plug into py_set_a versus py_set_b changes the answer.

It's one of the set-algebra nodes in aria1th's ComfyUI-LogicUtils, a personal utility pack from the handle behind the Illustrious XL training work. The pack's overall footprint online is thin - this is a side project, not a headline pack - but the set family (Create, Add, Remove, Clear, Union, Intersection, Difference, Symmetric Difference, Set to List) is a clean, working port of Python's set type.

How it works

It runs Python's py_set_a - py_set_b: everything left in A after removing anything also found in B. Practically, this is the "new items only" or "what did I miss" node - feed it a "seen/processed" set as B and a "current batch" set as A, and the output is exactly the unseen ones. Or flip it: feed a "required" set as A and a "have" set as B, and the output tells you what's still missing.

Because it's not symmetric, it's worth being deliberate about which set goes in which slot - get it backwards and you'll get the complement of what you meant, silently, since there's no error for "wrong direction," just a different (valid) answer.

Inputs and outputs

  • py_set_a (SET, required) - the set to subtract from.
  • py_set_b (SET, required) - the set being subtracted.
  • Output: SET - items in py_set_a that are not in py_set_b.

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. It's a CPU-side Python set operation - no models, no meaningful runtime or VRAM cost.

Common issues & troubleshooting

"Missing node type" on a workflow you didn't build. Use ComfyUI Manager's "Install Missing Custom Nodes" to grab the whole pack from the graph JSON in one step.

Import error on launch. The README documents an opt-in auto-installer for the pack's dependencies: set COMFYUI_LOGICUTILS_AUTO_INSTALL=1 before starting ComfyUI if a node's dependency didn't get pulled in, or COMFYUI_LOGICUTILS_SKIP_INSTALL=1 to disable the hook if that's what's causing the error. SetDifferenceNode needs nothing beyond the standard library - a failure here traces back to something else in the pack.

"The result is the opposite of what I expected." This is almost always the A/B inputs swapped - check which set is py_set_a and which is py_set_b before assuming the node is broken. Difference isn't symmetric by design.

Downstream node rejects the output. SET only connects to LogicUtils' own set nodes. Convert with Set to List before wiring it into a node expecting a plain LIST.

CategoryData

Inputs (2)

NameTypeDefaultDescription
py_set_aSET
py_set_bSET

Outputs (1)

NameTypeDescription
SETSET