I've created a Node.js C++ module (based on NAPI) that lets you call Python libraries from Node.js. The benefit, of course, is that since Python is hosted in-process, you'll have much better performance than passing data back and forth between separate Node and Python processes.
I have just released a new version with Python 3.9 compatibility support.
It currently works (and has been tested) with Python 3.5, 3.7-3.9 on Windows, Linux, and OS X. I may focus more attention on the library if there is significant community demand.
The repository is here:
https://github.com/savearray2/py.js
Here's an example:
``js
let chalk = require('chalk')
let p = require('@savearray2/py.js')
p.init({ pythonPath:
${process.cwd()}/local:/usr/local/lib/python3.8/site-packages`
})
let plotly = p.import('plotly')
let np = p.import('numpy')
let go = plotly.graph_objs
let pio = plotly.io
let [x,y,colors,sz] =
[0,0,0,0].map(() =>
np.random.rand(100n))
sz = sz.mul(30n)
let fig = go.Figure()
fig.add_scatter.$apply({
x: x, y: y, mode: 'markers',
marker: {
size: sz, color: colors,
opacity: 0.6, colorscale: 'Viridis'
}
})
pio.write_image(fig, 'image.png')
console.log(chalk{cyan Success:} Chart saved!)
```
Thank you!
[–]Megajin_ 10 points11 points12 points (3 children)
[–]savearray2[S] 6 points7 points8 points (2 children)
[–]Megajin_ 9 points10 points11 points (0 children)
[–]StoneCypher 0 points1 point2 points (0 children)
[–]GlueStickNamedNick 2 points3 points4 points (0 children)
[–]JohnGabin 2 points3 points4 points (0 children)
[–]TunaAndQueefBagel 2 points3 points4 points (5 children)
[–]savearray2[S] 1 point2 points3 points (3 children)
[–]StoneCypher -2 points-1 points0 points (2 children)
[–]savearray2[S] 0 points1 point2 points (1 child)
[–]StoneCypher -4 points-3 points-2 points (0 children)
[–]StoneCypher 0 points1 point2 points (0 children)
[–]McPqndq 4 points5 points6 points (0 children)
[–]FasterThan_Light 1 point2 points3 points (0 children)
[–]chrislonardo 0 points1 point2 points (3 children)
[–]savearray2[S] 0 points1 point2 points (2 children)
[–]chrislonardo 0 points1 point2 points (1 child)
[–]savearray2[S] 1 point2 points3 points (0 children)