Alternative StdLib for Nim for Python targets
Documentation
✔️ atexit➡️ https://juancarlospaco.github.io/cpython/atexit.html✔️ base64➡️ https://juancarlospaco.github.io/cpython/base64.html✔️ binascii➡️ https://juancarlospaco.github.io/cpython/binascii.html✔️ binhex➡️ https://juancarlospaco.github.io/cpython/binhex.html✔️ builtins➡️ https://juancarlospaco.github.io/cpython/builtins.html✔️ bz2➡️ https://juancarlospaco.github.io/cpython/bz2.html✔️ cmath➡️ https://juancarlospaco.github.io/cpython/cmath.html✔️ codecs➡️ https://juancarlospaco.github.io/cpython/codecs.html✔️ codeop➡️ https://juancarlospaco.github.io/cpython/codeop.html✔️ colorsys➡️ https://juancarlospaco.github.io/cpython/colorsys.html✔️ compileall➡️ https://juancarlospaco.github.io/cpython/compileall.html✔️ copy➡️ https://juancarlospaco.github.io/cpython/copy.html✔️ crypt➡️ https://juancarlospaco.github.io/cpython/crypt.html✔️ curses➡️ https://juancarlospaco.github.io/cpython/curses.html✔️ decimal➡️ https://juancarlospaco.github.io/cpython/decimal.html✔️ dbd➡️ https://juancarlospaco.github.io/cpython/dbd.html✔️ dis➡️ https://juancarlospaco.github.io/cpython/dis.html✔️ doctest➡️ https://juancarlospaco.github.io/cpython/doctest.html✔️ ensurepip➡️ https://juancarlospaco.github.io/cpython/ensurepip.html✔️ errno➡️ https://juancarlospaco.github.io/cpython/errno.html✔️ faulthandler➡️ https://juancarlospaco.github.io/cpython/faulthandler.html✔️ fcntl➡️ https://juancarlospaco.github.io/cpython/fcntl.html✔️ filecmp➡️ https://juancarlospaco.github.io/cpython/filecmp.html✔️ fnmatch➡️ https://juancarlospaco.github.io/cpython/fnmatch.html✔️ gc➡️ https://juancarlospaco.github.io/cpython/gc.html✔️ getopt➡️ https://juancarlospaco.github.io/cpython/getopt.html✔️ getpass➡️ https://juancarlospaco.github.io/cpython/getpass.html✔️ gettext➡️ https://juancarlospaco.github.io/cpython/gettext.html✔️ glob➡️ https://juancarlospaco.github.io/cpython/glob.html✔️ grp➡️ https://juancarlospaco.github.io/cpython/grp.html✔️ gzip➡️ https://juancarlospaco.github.io/cpython/gzip.html✔️ hashlib➡️ https://juancarlospaco.github.io/cpython/hashlib.html✔️ hmac➡️ https://juancarlospaco.github.io/cpython/hmac.html✔️ html.entities➡️ https://juancarlospaco.github.io/cpython/html_entities.html✔️ imghdr➡️ https://juancarlospaco.github.io/cpython/imghdr.html✔️ imp➡️ https://juancarlospaco.github.io/cpython/imp.html✔️ importlib➡️ https://juancarlospaco.github.io/cpython/importlib.html✔️ keyword➡️ https://juancarlospaco.github.io/cpython/keyword.html✔️ linecache➡️ https://juancarlospaco.github.io/cpython/linecache.html✔️ logging➡️ https://juancarlospaco.github.io/cpython/logging.html✔️ lzma➡️ https://juancarlospaco.github.io/cpython/lzma.html✔️ marshal➡️ https://juancarlospaco.github.io/cpython/marshal.html✔️ math➡️ https://juancarlospaco.github.io/cpython/math.html✔️ mimetypes➡️ https://juancarlospaco.github.io/cpython/mimetypes.html✔️ nis➡️ https://juancarlospaco.github.io/cpython/nis.html✔️ operator➡️ https://juancarlospaco.github.io/cpython/operator.html✔️ os➡️ https://juancarlospaco.github.io/cpython/os.html✔️ pickle➡️ https://juancarlospaco.github.io/cpython/pickle.html✔️ pickletools➡️ https://juancarlospaco.github.io/cpython/pickletools.html✔️ pkgutil➡️ https://juancarlospaco.github.io/cpython/pkgutil.html✔️ pprint➡️ https://juancarlospaco.github.io/cpython/pprint.html✔️ pwd➡️ https://juancarlospaco.github.io/cpython/pwd.html✔️ py_compile➡️ https://juancarlospaco.github.io/cpython/py_compile.html✔️ quopri➡️ https://juancarlospaco.github.io/cpython/quopri.html✔️ random➡️ https://juancarlospaco.github.io/cpython/random.html✔️ re➡️ https://juancarlospaco.github.io/cpython/re.html✔️ readline➡️ https://juancarlospaco.github.io/cpython/readline.html✔️ reprlib➡️ https://juancarlospaco.github.io/cpython/reprlib.html✔️ resource➡️ https://juancarlospaco.github.io/cpython/resource.html✔️ runpy➡️ https://juancarlospaco.github.io/cpython/runpy.html✔️ secrets➡️ https://juancarlospaco.github.io/cpython/secrets.html✔️ shutil➡️ https://juancarlospaco.github.io/cpython/shutil.html✔️ signal➡️ https://juancarlospaco.github.io/cpython/signal.html✔️ site➡️ https://juancarlospaco.github.io/cpython/site.html✔️ sndhdr➡️ https://juancarlospaco.github.io/cpython/sndhdr.html✔️ spwd➡️ https://juancarlospaco.github.io/cpython/spwd.html✔️ statistics➡️ https://juancarlospaco.github.io/cpython/statistics.html✔️ struct➡️ https://juancarlospaco.github.io/cpython/struct.html✔️ subprocess➡️ https://juancarlospaco.github.io/cpython/subprocess.html✔️ sys➡️ https://juancarlospaco.github.io/cpython/sys.html✔️ sysconfig➡️ https://juancarlospaco.github.io/cpython/sysconfig.html✔️ syslog➡️ https://juancarlospaco.github.io/cpython/syslog.html✔️ tabnanny➡️ https://juancarlospaco.github.io/cpython/tabnanny.html✔️ tempfile➡️ https://juancarlospaco.github.io/cpython/tempfile.html✔️ termios➡️ https://juancarlospaco.github.io/cpython/termios.html✔️ textwrap➡️ https://juancarlospaco.github.io/cpython/textwrap.html✔️ timeit➡️ https://juancarlospaco.github.io/cpython/timeit.html✔️ token➡️ https://juancarlospaco.github.io/cpython/token.html✔️ tty➡️ https://juancarlospaco.github.io/cpython/tty.html✔️ turtle➡️ https://juancarlospaco.github.io/cpython/turtle.html✔️ unicodedata➡️ https://juancarlospaco.github.io/cpython/unicodedata.html✔️ uu➡️ https://juancarlospaco.github.io/cpython/uu.html✔️ uuid➡️ https://juancarlospaco.github.io/cpython/uuid.html✔️ venv➡️ https://juancarlospaco.github.io/cpython/venv.html✔️ warnings➡️ https://juancarlospaco.github.io/cpython/warnings.html✔️ webbrowser➡️ https://juancarlospaco.github.io/cpython/webbrowser.html✔️ winsound➡️ https://juancarlospaco.github.io/cpython/winsound.html✔️ zipapp➡️ https://juancarlospaco.github.io/cpython/zipapp.html✔️ zlib➡️ https://juancarlospaco.github.io/cpython/zlib.htmlMore supported modules soon...
Open an issue for more Python libraries that you want wrapped! (1 issue per 1 lib).
For more documentation, use Python official documentation, works too.
Design
- 1 Dependency only.
- 1 Nim module per 1 Python module.
- Module files are <200 lines each of pure Nim code.
- Arbitrary precision big Decimals with all the operators for Nim.
- Compatible with ARC and ORC deterministic memory nanagement.
- Enforces real strong inferred static typing with UFCS for Python.
- Same API as Python StdLib, same function names, same argument names (Names starting and ending with double underscore are not legal in Nim).
- Use the vanilla official Python StdLib that you already know by memory.
- Same module filenames as Python StdLib, same imports as Python StdLib.
- Documentation online, but also any Python documentation should work too.
- Simple code using template, easy to hack for new users, KISS & DRY.
- Stuff deprecated/removed in Python before year 2020 will not be supported.
- We do not deprecate stuff, even if Python deprecate/remove it, it will keep working for Nim.
- Each file is completely self-contained standalone, you can copy just 1 file on your project and use it.
- If Python removes a module from StdLib you must obtain the
.py
file somehow, but the.nim
remains. - It does not use anything from Nim standard library, very future-proof (uses Nimpy for Python-Nim interop, but other than that they are thin wrappers, with minimal dependency on StdLib).
- Package version == Python version.
- Pet the turtle.
Requisites
- Python ( >
2.7
works but unsupported, >3.5
minimal, >=3.10
recommended ).
Install
nimble install cpython
OR
nimble install https://github.com/juancarlospaco/cpython.git
Stars
Doing JavaScript or Web Dev ?
Why?
The idea comes from the community of "Nim en Espanol" Telegram group (Spanish).
Also...
- Whole new StdLib becomes usable for Nim, without Nim having to spend resources.
- Showcase easy interoperability of Nim (CTypes is harder, Python is verbose, etc).
- Arbitrary precision big Decimals for Nim.
- Others do it too (Scala/Kotlin uses Java StbLib, Swift uses Objective-C StdLib, etc).
- Python does it too, Python is written in C therefore using C StdLib.
- Make others work improving libs that you can use in Nim.
- A place to pile up "Nim-ified" Python stuff.