npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@rosepetal/node-red-contrib-rosepetal-python-executor

v1.0.0

Published

A Node-RED node for executing Python code, similar to the function node but for Python

Readme

node-red-contrib-rosepetal-python-executor

Python into your Node-RED flows with a node that feels familiar, stays friendly, and keeps things fast when you need it.

Example

What You Get

  • Run small Python snippets whenever a message arrives.
  • Reuse your favorite Python tools without leaving Node-RED.
  • Choose between quick start-up or high-speed processing.
  • See clear status updates so you always know what is happening.

Before You Start

  • Install Python 3 on the machine running Node-RED.
  • Know where your Python interpreter lives (for most systems it is python3).

Node Options

  • Name – Optional label that appears on the canvas.
  • Python Path – The command Node-RED should run (for example python3 or a full path if you use a virtual environment).
  • Timeout – How long to wait for Python to finish before giving up. Useful to stop code that gets stuck.
  • Python Code – Your script. It always receives a message named msg, and whatever you return is passed along.
  • Hot Mode – Keeps Python processes running between messages for faster responses.
  • Workers – How many hot workers to run in parallel (only appears when Hot Mode is on). Use more workers when you expect bursts of messages.
  • Preload Imports – Optional lines that run once when each hot worker starts. Handy for heavier libraries you do not want to import on every message.

Cold vs Hot Mode

  • Cold Mode (default) – Starts a fresh Python process for every message. Great for occasional runs or quick experiments.
  • Hot Mode – Keeps a pool of Python workers ready. Messages are handled much faster after the first one. Best for frequent or time-sensitive flows.

Typical Flow

  1. Drop the python executor node into your flow.
  2. Connect an Inject node (input) and a Debug node (output).
  3. Add a short script, for example:
    msg['payload'] = f"Hello, {msg.get('payload', 'world')}!"
    return msg
  4. Deploy and trigger the flow. Adjust options as needed.

Benefits At A Glance

  • Familiar: Works just like the standard function node, only in Python.
  • Flexible: Supports both simple scripts and larger libraries.
  • Fast: Hot mode cuts response time dramatically for repeat work.
  • Clear: Status messages and notifications help you see what is working and what needs attention.
  • Binary Friendly: Hot workers stream large Buffers through shared memory instead of JSON, so images and other blobs stay fast.

Handling Large Binary Payloads

  • Hot workers drop large Buffers into /dev/shm (or your system temp dir) and hand Python the file handle so bytes never touch JSON.
  • Python can return bytes, bytearray, or memoryview; the worker writes them back to shared memory and Node converts them to Buffers automatically.
  • If the filesystem path is unavailable, the system falls back to base64 as a safety net (slower but still works).
  • Temporary blobs are cleaned up as soon as each request finishes—no manual housekeeping required.
  • The optimization is automatic—just enable hot mode when you expect heavy binary traffic.

Enjoy mixing Python logic into your Node-RED projects without extra fuss. When you are ready for more performance, flip on Hot Mode and keep building.