Isolated kernels
Capytale users
If you use Basthon in Capytale, see Capytale's documentation on isolated kernels (in French).
Since early 2026, Basthon's kernels are isolated. This means that the code runs in an environment separate from the one that runs and renders the web page. This brings:
- more security: the code run has no access to the user's credentials on Capytale, and therefore cannot make requests to the server behind their back;
- parallelism: a long computation does not block the page, and the kernel can be interrupted;
- a smoother rendering: the interactions with the user (
printandinputin Python) are shown in real time; - but with a few limitations: for instance, a few features of the
p5module in Python (playing videos, loading libraries) are not available (see below).
Info
How isolated kernels work (an opaque-origin worker, isolated frames, encrypted inputs) is described in Architecture and security.
Which kernels are isolated?
All of them: Python, OCaml, JS, SQL, XCAS, C and R.
The special case of the p5 Python module
The p5 module works with isolated kernels. The drawing is computed in the kernel and then shown in a frame isolated from the page, which passes the interactions (mouse, keyboard, touch screen) on to the kernel.
A few differences are worth knowing:
- for the sketch to react to the keyboard, click on it first (a coloured outline shows that it receives the keys);
loadImageloads the images of the local filesystem: files opened in Basthon, created by Python or, for the examples of the gallery, extra files. A relative path (loadImage("image.png")) means a file of this filesystem;- HTML elements (
createButton,createSlider,createInput,createSelect,createCheckbox,createRadio,createP...) are shown below the sketch (or at the position given byposition(x, y), relative to the top left corner of the sketch), but their actual size and position cannot be read (size()andposition()without arguments return 0); - the webcam (
createCapture(VIDEO)) asks for a confirmation at each call, on top of the browser's permission. It is released when the sketch is replaced by another one or when the kernel restarts; - sound (
p5.sound:loadSound,Oscillator,FFT...) works; as for images, a relative path (loadSound("sound.mp3")) means a file of the local filesystem. Sounds stop with the sketch; - some features are not available yet: playing videos and audio files through HTML elements (
createVideo,createAudio), capturing the microphone (createCapture(AUDIO)) and loading libraries (load_library).
To use these features, see the section How to get the non-isolated kernels back?.
The special case of the matplotlib Python module
The matplotlib module works with isolated kernels, interactive figures included. The figure is computed in the kernel and then shown in a frame isolated from the page: coordinates under the mouse, zoom, pan, history of the views, mouse and keyboard events (mpl_connect), animations and export of the figure (PNG, SVG, PDF...) through the download button after choosing the format.
As with p5, for the figure to react to the keyboard, click on it first.
How to get the non-isolated kernels back?
These kernels are called legacy. Add the -legacy suffix to the kernel= URL parameter. For instance, https://console.basthon.fr/?kernel=python3-legacy uses the non-isolated Python kernel.
Only the Python kernel has a legacy mode. It allows the features of p5 that are not available in the isolated kernel (see above) and direct access to the web page from Python (from js import document). On the other hand, tkinter is not available there. The OCaml, JS, SQL, XCAS, C and R kernels only exist in an isolated version: a link to one of them in a legacy version (for instance kernel=ocaml-legacy) opens the isolated version.