NPython
Python interpreter implemented in Nim, supporting JS backends
Summary
| Latest Version | Unknown |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:24 |
Tags
Installation
nimble install NPython
choosenim install NPython
git clone https://github.com/nimpylib/NPython
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| NPython | ✓ | ✓ | ✓ | - | - | - | - | - | ✓ | - |
Source
| Repository | https://github.com/nimpylib/NPython |
|---|---|
| Homepage | https://nimpylib.org |
| Registry Source | nimble_official |
README
NPython
Python programming VM implemented in Nim.
Online playground demo ↓ |
Read API Docs |
| (by compiling Nim to Javascript) | Wiki about History |
Purpose
- Fun and practice. Learn both Python and Nim.
- Serve as a altertive small version of CPython (as of 0.1.1, less than 2MB on release build mode)
- Used as plugin for those using WASM
How to use
Easiest installation
nimble install npython
Then you can use as if using python, e.g.
npython --version
npython -c "print('hello, NPython')"
Manually Install (e.g. JS backend)
Or you may wanna build for js backend or something else:
prepare
git clone https://github.com/nimpylib/npython.git
cd npython
NPython support C backend and multiply JS backends:
after build passing
-hflag to npython and you will see help message
For a binary executable (C backend)
nimble build
bin/npython
For a WASM executable (wasi-sdk backend)
nimble buildWasm
wasmtime --invoke NimMain bin/npython.wasm
For JS backend
- NodeJS:
nimble buildJs -d:nodejs - Deno:
nimble buildJs -d:deno - Browser, prompt&alert-based repl:
nimble buildJs -d:jsAlert - single page website:
nimble buildKarax(requiresnimble install karax). This is how online playground runs - es6 library for non-native environment:
nimble buildJsLib
Status
Capable of:
* flow control with if else, while, for, ...
* function (closure) defination and call. Decorators.
* builtin print, dir, len, range, tuple, list, dict, exceptions, etc.
* import such as import foo.
* raise exceptions, basic try ... except XXXError ..., with detailed traceback message. Assert statement.
* interactive mode and file mode
* ...
Check out ./tests to see more examples.
Todo
- integrate with nimpylib
- builtin compat dict
- better bigint lib
- ... ref Todo on Wiki