-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-84461: Add sys._emscripten_info, improve docs and build (gh-91781) #91781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
91bfe71
to
3acf409
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the recipe using this new attribute to test if Python runs in a browser?
def is_browser():
return (not sys._emscripten_info.runtime.startswith("Node.js ")
and sys._emscripten_info.runtime != "UNKNOWN")
Is that correct? What if the browser lies to set its user agent to "Node.js v1.0"?
Maybe you can rename runtime to runtime_version, and add a new runtime_name member which would be: "browser", "node" or "unknown"?
sys.implementation separates the Python implementation name from its version for example.
Why would you want to know that? The |
I expect that some things only work on Node but not in a browser. For example, we might use it to skip some tests. If all runtime would be the exactly the same, it wouldn't be useful to add this new sys attribute :-) Python has many variables like that, used to skip tests: sys.thread_info, sys.int_info, sys.implementation, etc. |
I call YAGNI It is unlikely that we need to differentiate between browser and node as runtime. If we ever need to check for it, then a naive browser vs. node is probably insufficient. Instead we will have to check for optional WASM runtime features like simd128, atomics, or SAB. Let's revisit the problem when it arises. The API is deliberately marked as private and provisional for 3.11. |
If they would be the same, the list of disabled C extensions would be the same.
That's a different issue, no? |
That is a different issue. |
Nice enhancement! |
No description provided.