pop random
Pop a random element — reproducibly, if you want
- set
- set
- item
pop random does what the name promises: it removes a random element from a set and returns both the updated set and the removed element. And unlike the plain pop node - which removes an "arbitrary" element you can't control - this one gives you a seed so the pick can be reproducible.
This is the node for "choose one at random from my pool." Picking a random style tag from a curated set, drawing a random prompt variation, choosing a random seed from a candidate pool - that's this node's lane. The dual outputs matter: you get the picked item for whatever needs it and the shrunken set, so you can feed it back in and keep drawing without replacement until the pool's empty. It composes with length to know when you've drained it.
How it works
The mechanism is random.choice under the hood: the node copies the set, picks a random element, removes it, and returns (new_set, item). The seed input is the interesting part:
- With a seed set, the pick is reproducible - the same seed on the same set yields the same element. This matters if you want your workflow to be shareable and stable.
- The seed widget has
control_after_generateon, meaning it steps forward after each run by default. Leave it on auto-increment and every run draws a different element; set it to fixed and the node's result is cached and repeated until you change it.
Also note the IS_CHANGED behavior in the source: when no seed is provided the node always recalculates (so every run picks fresh); with a seed it only recomputes when the seed changes. Empty set? You get the set back unchanged with item as None - no crash.
Inputs and output
set(SET) - the set to draw from.seed(INT, optional, default0) - reproducibility knob.0to2^64-1, with the standard control-after-generate widget.set(SET, output) - the set minus one element.item(ANY, output) - the randomly removed element, orNonefor an empty set.
Installing
It's in Basic data handling by StableLlama. ComfyUI Manager - search "Basic data handling", install, restart - is the easy path. Manual install:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart ComfyUI after cloning. The pack has zero dependencies and no model downloads, so there's nothing to fetch beyond the code.
Common issues
The thing that trips people is the caching when the seed is fixed. If you set seed to a constant and re-run, the same element comes out every time - that's not a bug, it's the reproducibility you asked for. To get fresh random picks each run, leave the seed's control_after_generate stepping. And remember sets hold only hashable values: if your pool contains lists or tensors, it was never a valid set in the first place.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| set | SET | — | |
| seedopt | INT | 00–18446744073709550000 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| set | SET | — |
| item | * | — |