これは既存PythonコードをWorkerで動かしたい人向け。
新規に実装するなら処理速度でJSが有利。
JSの起動はV8のisolate生成そのもので、これがWorkersの最小単位。
PythonはそのisolateのなかにWasm版CPythonを立てて、さらにPythonコードを読み込む。
Code Modeで使う場合もJSの方が明確に有利。
AIはPythonと同様にJSも書けるし、Code Modeで書くのはバインディングやツールを呼び出すだけのコードなのでPython固有のライブラリは要らない。
Pythonにしかないライブラリを使いたい場合はデプロイ済みのPython Workerで使う。
ただし動くのはpure PythonかWasm向けにビルドされたwheelがあるものだけで、C拡張ありのライブラリは対応状況次第。
参照(公式)
"your code is interpreted directly by Pyodide, within a V8 isolate."
"we perform the expensive initialization work at deploy time, rather than at runtime."
https://t.co/LCo7Kt2sQJ
"Python Workers are currently much slower to start than JavaScript Workers. For one-off AI-generated code, we strongly recommend using JavaScript. AI can write either language equally well."
https://t.co/WLfaEJlib3
"any packages with native C/C++/Rust extensions must be cross-compiled to WebAssembly"
https://t.co/mkJil7WLN3
We're excited to announce that today Python Workers are generally available (GA).
It means Python is now a first-class, fully supported language on the Cloudflare Developer Platform. Read everything about it: https://t.co/ZwQe6IPd93