TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Reviving PyMiniRacer: A Python <> JavaScript Bridge

47 点作者 jbaviat大约 1 年前

5 条评论

simonw大约 1 年前
This looks very promising!<p>The problem I most want to solve with this kind of library is execution of untrusted user-provided code in a sandbox.<p>For that I need three things:<p>1. Total control over what APIs the user&#x27;s code can call. I don&#x27;t want their code being able to access the filesystem, or run subprocesses, or make network calls - not without me explicitly allowing a controlled subset of those things.<p>2. Memory limits. I need to be able to run code without fear that it will attempt to allocate all available memory on my computer - generally that means I want to be able to set e.g. a 128MB maximum on the amount it can use.<p>3. Time limits. I don&#x27;t want someone to be able to paste &quot;while true() {}&quot; into my system and consume an entire CPU thread in an infinite loop. Usually I want to say something like &quot;run this untrusted code and throw an error if it takes more than 1s to run&quot;<p>My most recent favourite solution to this is the <a href="https:&#x2F;&#x2F;pypi.org&#x2F;project&#x2F;quickjs&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pypi.org&#x2F;project&#x2F;quickjs&#x2F;</a> Python library wrapper around QuickJS, which offers those exact features that I want - memory limits, control over what the code can do, and a robust time limit.<p>(The one thing it&#x27;s missing is good documentation, but the <a href="https:&#x2F;&#x2F;github.com&#x2F;PetterS&#x2F;quickjs&#x2F;blob&#x2F;master&#x2F;test_quickjs.py">https:&#x2F;&#x2F;github.com&#x2F;PetterS&#x2F;quickjs&#x2F;blob&#x2F;master&#x2F;test_quickjs....</a> test suite covers all of those features and is quite readable.)<p>Can PyMiniRacer handle those requirements as well?
评论 #39804943 未加载
评论 #39804732 未加载
评论 #39813985 未加载
评论 #39804066 未加载
评论 #39804226 未加载
nickpsecurity大约 1 年前
On a related note, Brython lets you run Python in the browser through JavaScript. You can even see Python in the HTML with “text&#x2F;python” SCRIPT tags.<p><a href="https:&#x2F;&#x2F;brython.info&#x2F;" rel="nofollow">https:&#x2F;&#x2F;brython.info&#x2F;</a>
leontrolski大约 1 年前
I&#x27;m always excited by the idea of rendering jsx from Python in the same process. Mostly as a bridge between eg. an existing Django app and full SPA React land. You&#x27;d swap out the scrappy Django string templating with jsx, then once a page passes some frontend interaction complexity threshold shift it over entirely (with shared components between both). Could this project help achieve this or are imports&#x2F;build processes etc too much of an impediment?
评论 #39804751 未加载
评论 #39803764 未加载
rossant大约 1 年前
There&#x27;s also <a href="https:&#x2F;&#x2F;pyodide.org&#x2F;en&#x2F;stable&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pyodide.org&#x2F;en&#x2F;stable&#x2F;</a>
punnerud大约 1 年前
All the JSON that work with JavaScript, but not on Python. Finally a good solution?