Python programming VM implemented in Nim.
Online playground demo ↓ |
Read API Docs |
| (by compiling Nim to Javascript) | Wiki about History |
- 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)
nimble install npythonThen you can use as if using python, e.g.
npython --version
npython -c "print('hello, NPython')"Or you may wanna build for js backend or something else:
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
nimble build
bin/npython
- 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
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.
- integrate with nimpylib
- builtin compat dict
- better bigint lib
- ... ref Todo on Wiki