ComfyUI Node

_.zip

Merge parallel lists into pairs, like Python's zip

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

_.zip merges the values of several arrays by position, exactly like Python's built-in zip. Two lists - ["a", "b", "c"] and [1, 2, 3] - become [["a", 1], ["b", 2], ["c", 3]]. The Underscore docs describe it as "useful when you have separate data sources that are coordinated through matching array indexes," which is precisely the Comfy situation: filenames in one list, prompts in another, and you want them paired up before they hit a loop or a formatter.

It comes from the ovum/underscore family in comfy-ovum, and the README's family warning is worth repeating: these generated wrappers are called "an absolute disaster to use in production," WIP. _.zip is one of the more predictable members - it's a direct port of a trivial operation - but it does share the family's quirks around generic inputs and JSON formatting for varargs.

How it works

Every _. method node wraps underscore3, the vendored Python port of Underscore.js. This one calls zip, which takes the first element of each array and groups them, then the second, and so on - a transposition, really. The result is a list of tuples/lists, one per index, truncated to the shortest input. [1,2] and ["a","b","c"][[1,"a"],[2,"b"]]; the extra "c" gets dropped, so keep your lists the same length unless you want silent truncation.

Chain mode works like its siblings: pass a _.CHAIN to continue the pipeline; pass plain lists to get the result directly.

Inputs and output

  • py_list - the first array (type *, optional; also accepts a _.CHAIN).
  • arrays - the additional arrays. Multiple arrays go in as a JSON array of arrays, e.g. [["a","b"], [1,2]]. This is the input people consistently trip on: it's one socket expecting JSON, not one socket per extra list.
  • Output: LIST.

Install

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

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

Restart. No model downloads; underscore3 is bundled in the repo.

When it earns its keep

Pairing up correlated lists is the classic job: zip filenames with their per-frame prompts, zip seeds with captions, zip any two things that were generated by separate processes but share an index. If you're already deep in list-manipulation territory with this pack's other utilities (uniq, without, zipObject), _.zip slots in naturally. If you never coordinate parallel lists, it's another node you'll happily never open.

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