News

VS Code Preview: Python in the Browser, Executed by WebAssembly

In the December update to Python in Visual Studio Code, developers can experiment with a new preview feature that lets them run and debug Python code in the browser.

The team develops the Python extension in the VS Code Marketplace, which also automatically installs the associated Jupyter extension and the Pylance language server, for providing Python-specfic "smarts" like auto-completion and so on. Those three tools are by far and away the most popular items in the VS Code Marketplace, with more than 72 million installs for the main tool, 53 million installs for the Jupyter tool and 45 million for Pylance.

In the new update, the preview experiment for browser-based Python coding works only with the browser-based implementation of VS Code, accessed at https://vscode.dev/. To do so, it relies upon WebAssembly, the open source tech that makes Blazor possible by letting developers use C# instead of JavaScript. Specifically, it provides a portable compilation target for C# code in client-side Blazor WebAssembly.

However, the experiment isn't ready for prime time, nor is it clear if it ever will be.

"There's a new VS Code extension that allows you to try running Python code in the Web using WebAssembly as an execution engine," the dev team said in announcing what's new in the latest monthly update. "Please note that this extension is being used for experimental and research purposes to gain an understanding of running Python code in the Web using WebAssembly and should not be used for production Python development as there are significant limitations."

What's more, developers have to jump through several hoops -- eight in all -- to get it working (this reporter couldn't even get it to work even following instructions explicity).

[Click on image for larger view.]

Even so, the Experimental - Python for the Web (Preview) extension in the VS Code Marketplace has been installed 283 times as of this writing (see screenshot above). The item description lists the experiment's limitations:

  • Python interpreter limitations
    • no pip support.
    • no socket support.
    • no support for native Python modules.
    • no thread support. As a consequence there is no async support either.
  • VS Code limitations
    • no debug support. You can only run a Python file.

New functionality that can be used in production includes improvements to auto indentation in Pylance.

"The Pylance extension for VS Code is working to improve our auto indent feature through its deeper understanding of Python!" the team said. "This feature allows you to focus more on the logic of your code and less on formatting. Try it out in VS Code Insiders using the Pre-Release version of the Python extension!"

Several other enhancements and fixes were detailed in the announcement post and can be explored further in the changelogs for Python, Jupyter and Pylance.

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus

Featured

Subscribe on YouTube