Retool workflow python code block slow warmup

Hi, we’re currently using a python code block in our workflows, and it seems to be very slow, with a simple return statement taking 7-10 seconds to run.

From my investigation, it seems like a majority of that time is used to start up the workflow code block, which takes 8 whole seconds, see screenshot below.

Is there a way I could improve this? This is very slow compared to its Javascript code block counterpart.

Hi @Marisa_Tjoe,

This is a known limitation of Retool's Python code blocks in Workflows. The 7-10 second cold start is essentially the overhead of spinning up a Python runtime/sandbox environment, which is fundamentally heavier than the JS runtime (which is already running in the browser/Node context).

Ways to reduce the impact

1. Switch to JavaScript where possible If your Python block isn't doing anything Python-specific (pandas, numpy, specific libraries, etc.), migrating the logic to a JS code block will give you near-instant execution. This is the most impactful change.

2. Consolidate Python blocks Each Python block incurs its own cold start. If you have multiple Python steps in a workflow, try merging them into a single block. One 8-second startup vs. three 8-second startups makes a big difference.

3. Move heavy Python logic to an external API If you need Python specifically (e.g. data science libraries), consider hosting the logic as a lightweight external endpoint (AWS Lambda, a FastAPI microservice, etc.) and calling it via a REST query block in Retool. Lambda cold starts are typically under 1 second for Python, and a warm Lambda is near-instant.

4. Avoid triggering the workflow synchronously in the critical path If the workflow result isn't needed immediately by the user, trigger it asynchronously and poll for the result or use a webhook callback. This way the UI isn't blocked waiting on the Python startup.

Let us know if you have any additional questions, @Marisa_Tjoe.