List Slice Ovum
List Slice Ovum — cut a sub-list out, JavaScript-style, without touching the original
- py_list
- *
ListSliceOvum returns a sub-list of your list using JavaScript-style slice semantics, without ever mutating the source. You say "give me the items from index 2 up to index 5," and you get a new list with exactly those elements. It's the maintained Python-list flavor of the pack's slice utility - the deprecated plain ListSlice is the same idea in the old ovum/lists/any family.
Why JS semantics instead of Python's? Because people who build workflows come from everywhere, and slice's rules are forgiving in a way that's genuinely handy in a graph: negative indices count from the end, out-of-range values get clamped instead of erroring, and you can leave the bounds blank. A slice that would be empty in Python's strict world just returns an empty list here.
Inputs and output
py_list- the source list. Must be a real Python list.start- optional, as aSTRINGwidget. Blank → 0. Negative →n + start, clamped to[0, n]. Positive → clamped to[0, n].end- optional, also aSTRING. Blank →n(the whole rest of the list). Negative →n + end, clamped. The end index is exclusive, soslice(0, 3)grabs items 0, 1, and 2.
Output is a new list containing py_list[start:end]. If start >= end after normalization, you get [] - no error, which is the behavior you want when feeding a possibly-empty result into a loop.
Why "exclusive end" and blank fields matter
Two things trip people up, both by design:
- End is exclusive.
start=1, end=3gives you indices 1 and 2 only. This matches JS and Python, but if you came from a "cut up to and including 3" mental model, you'll wonder why an item vanished. - Blank ≠ zero for
end. Leavingendblank means "to the end of the list." That's how you do "drop the first 2 items":start=2, blankend.
Where you'll use it
- Trimming lists before a fan-out. Take a big list of filenames and slice off the first N before processing.
- Splitting a list into chunks - slice
[0:n],[n:2n], etc. to feed parallel branches. - Loop batches. Inside a repeat loop, use a counter to slice a moving window out of a larger list each iteration.
It's non-mutating, so the original py_list stays intact for other branches - worth remembering when you're juggling several consumers of the same list.
Install
Ships in comfy-ovum:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
or ComfyUI Manager → comfy-ovum, then restart. No models, no keys.
Gotchas
- The
start/endwidgets are strings - a stray space or non-numeric text is treated as "blank," so you may get a bigger slice than you meant. Clean the fields. - Non-list input raises
ValueError: Input must be a Python list. start >= endreturns an empty list, not an error - make sure downstream nodes can handle empty input, or gate it withisListNotEmpty.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| py_list | * | — | |
| start | STRING | — | |
| end | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |