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

  • Creating Reactive Applications in .NET

    In modern applications, data is being retrieved in asynchronous, real-time streams, as traditional pull requests where the clients asks for data from the server are becoming a thing of the past.

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

Subscribe on YouTube