Nodes/comfy-ovum/_.grouper
ComfyUI Node

_.grouper

_.grouper

By sfinktah·Created about a year ago·Updated 10 months ago· 7
_.grouper
  • obj
  • fillvalue
  • *
n1

_.grouper chops a list into fixed-size chunks. The docs quote the classic recipe - grouper(3, 'abcdefg', 'x') gives you ('a','b','c'), ('d','e','f'), ('g','x','x') - which is exactly the itertools grouper recipe from Stack Overflow, wrapped for the graph. If you need to batch a flat list into pairs or triples, this is the node.

It's one of the _.* nodes in sfinktah/comfy-ovum, the author's grab-bag pack, wrapping underscore3 (a Python port of Underscore.js). Display name _.grouper, class UnderscoreGrouper.

The inputs that matter

  • obj - the list to chunk (loose *; also accepts a _.CHAIN).
  • n - chunk size, an INT, default 1. Set it to how many items per group.
  • fillvalue - an ANY input, JSON allowed. When the final group is short, this pads it out - like the 'x' in the example above. Leave it blank and the last chunk just comes up short.

Output is a loose *.

The honest catch about the output

Here's the thing I verified against the shipped code: grouper returns an itertools.zip_longest iterator, not a materialized list of lists. The chunks are there, but as a lazy iterator. That means the output is single-use (an iterator gets consumed once), and some downstream nodes will handle it fine while others want a real list. If you need the materialized form, plan on consuming it - this is a rough edge that fits right in with the family's "work in progress" status.

Why you'd reach for it

Batching is a legit pattern: turn a flat list of 12 settings into 6 pairs for a paired-input node, or group frame paths into batches. When a downstream node expects grouped input, _.grouper is the least-fiddly way to make the groups. Just keep the iterator caveat in mind.

Install

ComfyUI Manager, search "comfy-ovum", or:

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

Restart, under ovum/underscore. No models, no downloads.

Honest warnings

Family disclaimer: work in progress, "an absolute disaster to use in production." And unlike most of the family, _.grouper isn't really an Underscore.js method at all - it's the itertools recipe bolted on, so expect Python-flavored behavior. Chain rule: feed a _.CHAIN in, get a chain out; _.value to unwrap. And remember the iterator output.

Categoryovum/underscore

Inputs (3)

NameTypeDefaultDescription
objopt*Primary input object. Also accepts _.CHAIN to continue chaining.
noptINT1n (int)
fillvalueopt*fillvalue: JSON allowed for arrays/objects where applicable.

Outputs (1)

NameTypeDescription
**