Introducing Basilisk — build Python canisters on the Internet Computer

Hi ICP community!

My name is Jose and I wanted to share Basilisk, a Python CDK for the Internet Computer. These are the main highlights:

  • It runs CPython 3.13 — as opposed to Kybra which runs on RustPython — compiled to WASM. This means faster and cheaper applications, smaller WASMs and faster build times.

  • Standard library — As close to the full CPython standard library as the IC architecture allows. Modules like os, json, re, datetime, hashlib, collections work out of the box.

  • Remote shell — Execute Python on a live canister, on-chain and without redeploying.

  • Data introspection — Read-only query API to inspect your canister’s data.

  • Persistent filesystem — A simple file system (with limitations, waiting for the WASI filesystem interfaces expected from the upcoming Wasm Component Model support on ICP).

Optionally, basilisk users can add Basilisk Toolkit which includes out-of-the-box:

  • A persistent ORM (ic-python-db) — typed entities with properties, relationships, and versioning.

  • Schema upgrade safety — Motoko-like upgrade protection with pre-deploy CLI and on-chain enforcement in post_upgrade traps that atomically rolls back if a breaking change is deployed without migration, preventing data loss.

  • Task scheduling — run code at specific times and/or periodically.

  • Encryption — convenient use of vetKeys to encrypt data fields, manage per-user keys and group-based access control.

  • ICRC-1 wallet — conveniently manage any ICRC-1 token from the shell or code.

  • An interactive Python shell / REPL

  • SSH/SFTP into your canister’s filesystem — transfer files conveniently.

You can see two deployable full-stack templates at https://ic-basilisk.tech/.

I built Basilisk because I needed more performance and compatibility than what was available to build some serious projects on the IC.

I hope to get some interest from the dev community. Feel free to reach me if you have questions!

Congrats! Very cool project. How is the speed on the mainnet ?

Thanks! I would say the speed and overall performance on mainnet is quite OK. Here’s a benchmark against Rust and Motoko: GitHub - smart-social-contracts/basilisk: Python CDK for the Internet Computer · GitHub. I’ve been using it for a few months on my own projects (regular web-style applications with HTTP calls) and haven’t experienced any remarkable slowness or high cost so far. You can try 2 demo apps live on mainnet yourself here: https://ic-basilisk.tech/

sum_to(10000) (arithmetic loop)

FYI, if this is a Nat loop in motoko you may want to try a Nat64 as the Nat uses wasm bigint and is MUCH slower for arithmetic.

Thanks for flagging! Just changed to Nat64 and re-ran the benchmark and indeed the values dropped substantially. Are the new values more in line with what you would expect?

Yep. I’m curious, Does python use Ana unbounded Nat? Or is it a Nat64 or Nat32?

Yes, Python integers are unbounded (not Nat32 or Nat64). They are represented as an array of 30 bits digits. But in this benchmark, all values fit in a single digit, so there is no overhead due to multiple digits.

Amazing job. Congratulations.