javascript

PyMiniRacer v0.12.2

Call your Python from your JavaScript from your Python

The dynamic language embedding turducken is complete: you can now call Python from JavaScript from Python!

As of PyMiniRacer v0.12.2, you can write logic in Python and expose it to V8’s JavaScript sandbox. You can now in theory, while writing only Python and JavaScript, create your own JS extension library similar to NodeJS’s standard library. Obviously, anything created this way this will almost certainly be less extensive, less standardized, and less efficient than the NodeJS standard library; but it will be more tailored to your needs.

This post follows up on prior content related to reviving PyMiniRacer and then giving Python code the power to directly poke JS Objects, call JS Functions, and await JS Promises.

PyMiniRacer v0.11.1

Poke objects! Call functions! Await promises!

In this last blog post, I discussed my revival of PyMiniRacer, a neat project created by Sqreen to embed the V8 JavaScript into Python. As of that post (v0.8.0), I had done a light reorganization of the C++ side of PyMiniRacer, but nothing big there yet. Here we talk about some extensions to PyMiniRacer, rolling up the changes up to v0.11.1: JS Object and Array manipulation, directly calling JS functions from Python, async support, and a discussion of the C++ changes needed to make all that work.

Reviving PyMiniRacer

JS-in-Python, in-process, redux!

In this last blog post, I created a helper to call JavaScript from Python using a NodeJS sidecar process. In the post I commented that in- process JS evaluation might be nicer. The old Sqreen PyMiniRacer project had only recently fallen into disrepair. Can we revive it?

TL;DR: Yes! It just took a couple weeks of elbow grease, and new ownership (it me). I now own the two best ways to run JavaScript from a Python program: PyMiniRacer and nodejs-eval.

Running JavaScript from Python using NodeJS

It's RCE, but local!

I wanted to call a pile of JavaScript (actually transpiled TypeScript) from Python, so I could run reinforcement learning on this.

I was dissatisfied with the existing options for calling JS from Python, so I made a new thing!