_.uniq_mutate
Dedupe in place, and it deletes the wrong copy
- obj
- *
Here's the thing to know before you even install this one: _.uniq_mutate is _.uniq with a nasty twist. It dedupes the array in place - it mutates the original list instead of returning a copy - and because of how Python's list.remove works, it removes the earlier duplicate and keeps the later one. That's the exact opposite of normal uniq, which keeps the first occurrence. The author's own description spells it out: "due to way .remove works in python, the earlier duplicates will be removed, not the later ones."
So when would you want that? Honestly, almost never. This is a corner node in the ovum/underscore family of comfy-ovum, and it sits right in the middle of the pack's own warning: the README calls these auto-generated underscore wrappers "an absolute disaster to use in production," work in progress. uniq_mutate is a good example of why that warning exists - it's the kind of node that looks like a dedupe and then surprises you.
How it works
All the _. method nodes wrap underscore3, the Python port of Underscore.js bundled inside the repo. This one runs the port's uniq_mutate: it scans the sequence, marks every repeat, then calls list.remove on the original for each marked item. Because remove deletes the first match, the duplicates that die are the early ones - leaving the last occurrence in place. It also mutates whatever list you handed it, so anything else pointing at that same list sees the change. If you're feeding it a list you still need intact, use the regular _.uniq instead.
The chaining behavior is the same as its siblings: give it a _.CHAIN and it continues the pipeline; give it a plain list and you get the (mutated) result back.
Inputs and output
One input, obj (type *, optional). One output, *. No widgets to configure - wire in a list and go. Note the output type is generic *, so Comfy won't statically know it's a list.
Install
Manager: search comfy-ovum, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
Restart. No models, no extra dependencies for the underscore subset - underscore3 ships inside the repo.
The honest verdict
Use _.uniq. If you need a dedupe that doesn't mutate, that's the one. uniq_mutate only makes sense if you're processing a list you own outright, want to save a copy allocation on something huge, and genuinely don't care which duplicate survives. That's a thin set of circumstances, and the "last occurrence wins" behavior is easy to forget a week later when you're debugging. Consider this article the paper trail that someone warned you.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| objopt | * | Primary input object. Also accepts _.CHAIN to continue chaining. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |