_.size
The length of anything, as an integer you can use
- list_or_dict
- INT
_.size counts the number of values in a collection and hands you an integer. It's the boring, indispensable utility: how many items are in this list, how many keys in this dict, how many prompts did the wildcard processor expand to. In a node graph, "tell me how many things I have" is a question you need answered constantly - for loop bounds, for sanity checks, for deciding whether to branch at all.
It's part of the ovum/underscore family in comfy-ovum, auto-generated wrappers around underscore3, a Python port of Underscore.js that ships inside the pack repo. This is one of the simplest members, and the family's "work in progress, not for production" warning weighs least heavily here - len() is about as safe a thing as you can wrap. Still, know the wrapper's one quirk before you build on it.
Inputs and output
- list_or_dict (
*) - the collection. Lists, tuples, sets, and dicts all work; the underlying method just callslen(self.obj).
Output is an INT - the count. This is one of the few nodes in the family with a properly typed integer output, so it plugs straight into anything expecting an INT (loop counters, scheduler math, comparators).
The wrapper quirk: pass a _.CHAIN in as the primary input and _.size behaves like every other method node - it continues the chain and returns a _.CHAIN instead of a bare integer. You'd then unwrap with _.value. That's consistent with the family design, but it's easy to forget, because "size" feels like a terminal operation. If you wired a chain in and your count comes back as a chain object, that's why - add _.value downstream.
Install
# via ComfyUI Manager: search "comfy-ovum"
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
# restart ComfyUI
No models to download; pure Python. Manager installs the pack's declared dependencies (aiohttp, pillow, numpy, requests, and a few more) automatically, and underscore3 is bundled in the repo.
Where people get burned: _.size counts elements, not bytes or width. Feed it a string and you get the number of characters; feed it a list of lists and you get the number of inner lists, not the total of their contents. If you wanted the flattened count, run it through _.flatten (or the pack's list utilities) first.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| list_or_dictopt | * | Primary input object (expected collection). You can still pass any JSON-serializable value. Also accepts _.CHAIN to continue chaining. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |