ComfyUI Node

_.union

Merge several tag lists into one, duplicates gone

By sfinktah·Created about a year ago·Updated 10 months ago· 7
_.union
  • py_list
  • arrays
  • LIST

You've got three lists of prompt tags - one from a wildcard, one from a LoRA's trigger set, one you typed by hand - and you want one combined list with no repeats, in first-seen order. That's the entire job of _.union. It's a set union that keeps the ordering of first appearance, which is exactly what you want for tags, because union from a Python set() would scramble them.

Like every _. node in the comfy-ovum pack, this is an auto-generated wrapper around underscore3, the vendored Python port of Underscore.js. And like its siblings it carries the author's own warning in the README: "an absolute disaster to use in production," work in progress. For a list-merging utility that's a bit melodramatic, but the underscore family as a whole does have rough edges - read the sections below before you trust it with anything precious.

How it works

You give it a first array and then one or more additional arrays. It walks each array in order and keeps an item the first time it's seen, dropping later duplicates. So union(["a", "b"], ["b", "c"], ["c", "a"])["a", "b", "c"]. Underscore semantics, plain and simple.

The chaining mode applies here too: hand it a _.CHAIN and it continues the pipeline rather than returning a value; give it a plain list and you get the merged result. The two * inputs are how the extra arrays get in.

Inputs and output

  • py_list - the primary array (type *, optional).
  • arrays - the additional array(s). This is a vararg parameter, so to pass more than one extra array you provide a JSON array, e.g. [["b", "c"], ["c", "a"]]. The tooltip says exactly that, and it's the gotcha most people hit first: you can't just drag a second list onto a second socket, because there's only one arrays input.
  • Output: LIST.

Both inputs take JSON-parseable values or wired lists, and the primary input also accepts a _.CHAIN to continue a chain.

Install

Manager: search comfy-ovum, install, restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum

Restart, and you're done - no models, no extra pip installs for the underscore subset (the port is bundled in the repo).

Where people get burned

The arrays vararg is the main trap: if you type "b, c" instead of ["b","c"], it gets treated as one string. Keep the JSON shape in mind. Otherwise this is one of the more dependable nodes in the family - a set-union that respects order is a genuinely useful thing to have in a prompt-assembly graph.

Categoryovum/underscore

Inputs (2)

NameTypeDefaultDescription
py_listopt*Primary input object (expected array). You can still pass any JSON-serializable value. Also accepts _.CHAIN to continue chaining.
arraysopt*arrays: JSON allowed for arrays/objects where applicable. For multiple values, provide a JSON array (e.g., [1,2,3]).

Outputs (1)

NameTypeDescription
LISTLIST