List: Limit (lab)
Slice a list down to size, first or last
- list
- list
- count
List: Limit (lab) takes a list and keeps only the first nb_elements - or, flip a switch, the last nb_elements. That's the entire node. It exists because once you start building batch workflows out of lists, the number of "I don't want all 40 of those" moments is surprisingly high.
It sits between whatever generates a list and whatever consumes it, giving you a knob to say "just give me the first five." One tiny input, one tiny output, no surprises.
The inputs
- list - the list to slice from.
- nb_elements - how many to keep, default 1, minimum 1.
- method -
first(default) orlast. First keeps the head of the list, last keeps the tail.
Outputs are the standard list-node pair: list (the trimmed slice) and count (its length).
When you actually need it
The genuinely useful case is last, which has no obvious non-list equivalent. ComfyLab's List: Random Seeds regenerates a full batch each time you click - but pair it with List: Limit set to last and a fresh click gives you just the newest few seeds. Same trick applies to anything where "most recent N" is the thing you care about, which is most list-building workflows in practice.
It's also a cheap sanity clamp: a big sweep list feeding a queue, with a Limit node upstream saying "don't let this run exceed 10 images tonight." And in XY plots, trimming dim1 or dim2 down before the queue is an easy way to shrink a grid without editing the source list.
If the list is already short, nothing changes - slicing more than you have is a no-op, and an empty result is fine. No error here.
Install
ComfyLab Pack is one install for its whole family (nodes display with "(lab)" suffixes). ComfyUI Manager: search ComfyLab Pack, install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/bugltd/ComfyLab-Pack.git
cd ComfyLab-Pack
pip install -r requirements.txt
Restart after. No model downloads - the pack is pure tooling with light requirements.
Gotchas
nb_elementsminimum is 1. You can't produce an empty list with this node (use a different branch if you need zero).- "First" isn't always newest. Order in = order out; if the source list isn't sorted the way you think,
firstwon't magically pick the best five.
It's a two-line slice wrapped in a node - but it's the two-line slice you'd otherwise re-express in three different list utilities. Boring, predictable, occasionally the exact thing that unblocks a workflow.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| list | LIST | list to extract from | |
| nb_elements | INT | 1 | number of elements |
| method | COMBO | first | how to extract |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| list | LIST | limited list |
| count | INT | number of values |