Nodes/comfy-ovum/_.isCode
ComfyUI Node

_.isCode

'is this a compiled code object?'

By sfinktah·Created about a year ago·Updated 10 months ago· 7
_.isCode
  • obj
  • *

_.isCode checks whether a value is a Python code object - the compiled bytecode artifact Python creates when it compiles a function body, visible as the __code__ attribute on any function. It's the most niche type-check in this pack's introspection family, because code objects basically never show up in normal ComfyUI data flow.

How it works

A direct type comparison against Python's CodeType:

def isCode(self):
    return self._wrap(type(self.obj) is CodeType)

Functions are FunctionType, lambdas are LambdaType, but my_func.__code__ is a CodeType - the compiled thing, not the callable wrapper around it. This node is the only one in the family that tests for that specific artifact.

The inputs that matter

One input, one output:

  • obj - the primary input (*), the value being inspected. Also accepts a _.CHAIN to continue chaining.

Output is a single * - a real bool at runtime, untyped on the socket because the auto-generator only types standard Underscore.js method names.

Where you'd actually use it

Let's be straight: you almost certainly won't use this. To need it, you'd be introspecting functions at a level where you've pulled their __code__ attributes into the graph - deep meta-work around building or inspecting iteratees, way off the beaten path of even the pack's other introspection nodes. Its real role in the family is completeness: the underscore3 port translated Underscore.js's "is this a function?" questions into a whole suite of Python type checks, and isCode covers the compiled-code corner. Think of it as part of the API surface, not a tool you'll reach for.

Installing

Ships in comfy-ovum (MIT). ComfyUI Manager → search comfy-ovum → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum

No extra dependencies for the underscore nodes - the bundled underscore3 port covers them.

Gotchas

Untyped * output, WIP status per the pack README, and the fact that this check is exact: it matches CodeType and only CodeType. A function itself returns false; only its compiled __code__ passes. If you're debugging why a value "isn't a function," that's the distinction at play.

Categoryovum/underscore

Inputs (1)

NameTypeDefaultDescription
objopt*Primary input object. Also accepts _.CHAIN to continue chaining.

Outputs (1)

NameTypeDescription
**