ComfyUI Node

Logical OR

Short-circuiting, the other direction

By Duanyll·Created 11 months ago·Updated 4 months ago· 2
Logical OR
    • BOOLEAN
    input1
    input2

    Logical OR is the mirror image of the pack's Logical AND: True if either input is True, and short-circuiting on the opposite end - its own description says "If input1 is True, input2 is not evaluated." Once one side is already True, the OR's answer can't change, so ComfyUI skips the second input entirely.

    The inputs

    • input1 - first BOOLEAN.
    • input2 - second BOOLEAN, marked lazy.
    • output - BOOLEAN, the logical OR of the two.

    The lazy part is the reason to use this over a hand-rolled boolean merge. With OR, you want your cheap check on input1 - if it's True, you never pay for the expensive input2. Classic use: "use this setting if the user overrode it OR the auto-detector says so." If the user override is on, the detector doesn't need to run at all.

    How it works

    Same mechanism as Logical AND, flipped: check_lazy_status requests input2 only when input1 is False. When input1 is True it returns True directly and the executor never evaluates input2. Lazy evaluation is the pack's consistent philosophy - it's also how If Condition keeps the losing branch from running.

    A practical pattern

    Chaining several OR conditions is where this gets useful. Stack two OR nodes to merge three flags, and put the most likely-to-be-True check first on each one - you maximize the number of skipped evaluations. And because this is lazy, whatever sits on input2 only runs when it genuinely matters. Which is also the warning:

    Where people get burned

    • Side effects on input2 - if that branch logs or Sows anything, a True input1 means it never executes. Lazy is a feature, not a "sometimes it runs" deal.
    • Ordering by cost - the node can only skip input2, so the pricey check belongs there and the cheap check on input1. Reverse it and you pay the expensive bill on every run where the cheap check was True.
    • Not bitwise - it produces a Python boolean; three conditions need two stacked nodes.

    Installing it

    Part of Duanyll/comfyui_functional (logic category). ComfyUI Manager: search "Duanyll/comfyui_functional", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Duanyll/comfyui_functional
    # restart ComfyUI
    

    No models, no pip deps. Like its AND sibling, it's fully portable - no LISTs, no closures, drop it into any workflow that needs a lazy boolean merge.

    Categoryduanyll/functional/logic

    Inputs (2)

    NameTypeDefaultDescription
    input1BOOLEAN
    input2BOOLEAN

    Outputs (1)

    NameTypeDescription
    BOOLEANBOOLEAN