Alternative StdLib for Nim for Python targets

Overview

Alternative StdLib for Nim for Python targets

Documentation

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.

See also

Comments
  • questions

    questions

    • how did you generate the APIS? nimterop? (obviously not c2nim ...)

    • how is this maintained/kept up to date?

    • syntax highlight is broken eg https://github.com/juancarlospaco/cpython/blob/nim/src/cpython/base64.nim

    • Same API as Python StdLib, same function names, same argument names. => maybe give more details (eg regarding how trailing _ are handled, since illegal ... for now)

    • It does not use anything from Nim standard library, very future-proof.

    this needs clarification, because it uses nimpy (which itself uses stdlib)

    • nimpy (which is the thing that makes it all work) should be clearly mentioned (with a link also) in the README
    documentation enhancement good first issue 
    opened by timotheecour 6
  • theindex.html (and search) doesn't work

    theindex.html (and search) doesn't work

    eg https://juancarlospaco.github.io/cpython/theindex.html gives 404

    also, with such working index you wouldn't neeed to maintain a (manually generated?) README with the docs which does essentially the same;

    example

    see how other packages handle this, eg:

    • https://github.com/nitely/nim-regex => "Read the docs" https://nitely.github.io/nim-regex/regex.html
    • https://github.com/citycide/glob
    • https://github.com/kaushalmodi/std_vector
    documentation enhancement help wanted good first issue low priority 
    opened by timotheecour 4
  • actual Nim code?

    actual Nim code?

    Looking at the source, this is just using python under the hood, so same performance characteristics.

    The project is laudable, but why not replace at least the obvious parts with Nim code? Then it would make ported python that use your library much faster.

    invalid wontfix low priority 
    opened by kobi2187 2
  • boilerplate should be refactored

    boilerplate should be refactored

    these appear in each module (with minor modifications):

    template X(simbol):       auto = nimpy.pyImport("crypt").simbol().to(type(result))
    template X(simbol; a):    auto = nimpy.pyImport("crypt").simbol(a).to(type(result))
    template X(simbol; a, b): auto = nimpy.pyImport("crypt").simbol(a, b).to(type(result))
    

    can you instead add a private module pyutils which you import in each module, possibly with a macro eg:

    # pyutils.nim:
    macro genWrappers*(name: string) =
      template X(simbol):       auto = nimpy.pyImport(name).simbol().to(type(result))
      template X(simbol; a):    auto = nimpy.pyImport(name).simbol(a).to(type(result))
      template X(simbol; a, b): auto = nimpy.pyImport(name).simbol(a, b).to(type(result))
    
    # in crypt.nim:
    import pyutils
    genWrappers("crypt")
    
    ...
    
    enhancement help wanted good first issue low priority 
    opened by timotheecour 2
  • suggestion: add

    suggestion: add "Why" to Readme

    As a developer I want known why So that I can decide if I should use it or not

    My own experience: I could only realize why you did it, when you mention nodejs lib, maybe for someone without that previous knowledge it would be harder.

    Nice related content: https://sketchplanations.com/the-golden-circle

    Sorry it should be a pull request, but I'm not confident with my English neither the why or pros/cons, of use your lib.

    documentation 
    opened by hugosenari 1
Owner
Juan Carlos
.10x frAgile FullStuck Midend Devlooper, Python & Nim, Arch & OpenSource, EN|ES, Argentina, UTC-3, UTF-8, UFCS
Juan Carlos
The purpose of this tool is to check RDP capabilities of a user on specific targets.

RDPChecker The purpose of this tool is to check RDP capabilities of a user on specific targets. Programming concept was taken from RDPassSpray and thu

Hypnoze57 57 Aug 4, 2022
An Airdrop alternative for cross-platform users only for desktop with Python

PyDrop An Airdrop alternative for cross-platform users only for desktop with Python, -version 1.0 with less effort, just as a practice. ##############

Bernardo Olisan 6 Mar 25, 2022
An alternative site to emplea.do due to inconsistent service of the app.

feline a agile and fast alternative to emplea.do License: MIT Settings Moved to settings. Basic Commands Setting Up Your Users To create a normal user

Codetiger 8 Nov 10, 2021
An alternative app for core Armoury Crate functions.

NoROG DISCLAIMER: Use at your own risk. This is alpha-quality software. It has not been extensively tested, though I personally run it daily on my lap

null 12 Nov 29, 2022
A tool to flash .ofp files in bootloader mode without needing MSM Tool, an alternative to official realme tool

Oppo/Realme Flash .OFP File on Bootloader A tool to flash .ofp files in bootloader mode without needing MSM Tool, an alternative to official realme to

Italo Almeida 70 Jan 2, 2023
Todos os exercícios do Curso de Python, do canal Curso em Vídeo, resolvidos em Python, Javascript, Java, C++, C# e mais...

Exercícios - CeV Oferecido por Linguagens utilizadas atualmente O que vai encontrar aqui? ?? Esse repositório é dedicado a armazenar todos os enunciad

Coding in Community 43 Nov 10, 2022
PyDy, short for Python Dynamics, is a tool kit written in the Python

PyDy, short for Python Dynamics, is a tool kit written in the Python programming language that utilizes an array of scientific programs to enable the study of multibody dynamics. The goal is to have a modular framework and eventually a physics abstraction layer which utilizes a variety of backends that can provide the user with their desired workflow

PyDy 307 Jan 1, 2023
A Python script made for the Python Discord Pixels event.

Python Discord Pixels A Python script made for the Python Discord Pixels event. Usage Create an image.png RGBA image with your pattern. Transparent pi

Stanisław Jelnicki 4 Mar 23, 2022
this is a basic python project that I made using python

this is a basic python project that I made using python. This project is only for practice because my python skills are still newbie.

Elvira Firmansyah 2 Dec 14, 2022
Analisador de strings feito em Python // String parser made in Python

Este é um analisador feito em Python, neste programa, estou estudando funções e a sua junção com "if's" e dados colocados pelo usuário. Neste código,

Dev Nasser 1 Nov 3, 2021
Python with braces. Because Python is awesome, but whitespace is awful.

Bython Python with braces. Because Python is awesome, but whitespace is awful. Bython is a Python preprosessor which translates curly brackets into in

null 1 Nov 4, 2021
PSP (Python Starter Package) is meant for those who want to start coding in python but are new to the coding scene.

Python Starter Package PSP (Python Starter Package) is meant for those who want to start coding in python, but are new to the coding scene. We include

Giter/ 1 Nov 20, 2021
Py-Parser est un parser de code python en python encore en plien dévlopement.

PY - PARSER Py-Parser est un parser de code python en python encore en plien dévlopement. Une fois achevé, il servira a de nombreux projets comme glad

pf4 3 Feb 21, 2022
A community based economy bot with python works only with python 3.7.8 as web3 requires cytoolz

A community based economy bot with python works only with python 3.7.8 as web3 requires cytoolz has some issues building with python 3.10

null 4 Jan 1, 2022
A python script based on OpenCV-Python, you can automatically hang up the Destiny 2 Throne to get the Dawning Essence.

A python script based on OpenCV-Python, you can automatically hang up the Destiny 2 Throne to get the Dawning Essence.

null 1 Dec 19, 2021
Run python scripts and pass data between multiple python and node processes using this npm module

Run python scripts and pass data between multiple python and node processes using this npm module. process-communication has a event based architecture for interacting with python data and errors inside nodejs.

Tyler Laceby 2 Aug 6, 2021
inverted pendulum fuzzy control python code (python 2.7.18)

inverted-pendulum-fuzzy-control- inverted pendulum fuzzy control python code (python 2.7.18) We have 3 general functions for 3 main steps: fuzzificati

arian mottaghi 4 May 23, 2022
Izy - Python functions and classes that make python even easier than it is

izy Python functions and classes that make it even easier! You will wonder why t

null 5 Jul 4, 2022