Coder Social home page Coder Social logo

juancarlospaco / cpython Goto Github PK

View Code? Open in Web Editor NEW
139.0 5.0 3.0 38.11 MB

Alternative StdLib for Nim for Python targets, hijacks Python StdLib for Nim

Home Page: https://gist.github.com/juancarlospaco/37da34ed13a609663f55f4466c4dbc3e

License: MIT License

Python 100.00%
python python-library python3 python-3 python-package python-api nim nim-lang compiled cython

cpython's Introduction

Alternative StdLib for Nim for Python targets

Documentation

UPBGE

UPBGE API is supported out of the box, new UPBGE features will be integrated.

3D Games, GUI with OpenGL and shaders, audio, video, and more...

Are you Gamedev?, Pull Requests welcome!.

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

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

💰➡️🍕

Bitcoin BTC

BEP20 Binance Smart Chain Network BSC

0xb78c4cf63274bb22f83481986157d234105ac17e

BTC Bitcoin Network

1Pnf45MgGgY32X4KDNJbutnpx96E4FxqVi

Lightning Network

Ethereum ETH Dai DAI Uniswap UNI Axie Infinity AXS Smooth Love Potion SLP Uniswap UNI USDC

BEP20 Binance Smart Chain Network BSC

0xb78c4cf63274bb22f83481986157d234105ac17e

ERC20 Ethereum Network

0xb78c4cf63274bb22f83481986157d234105ac17e
Tether USDT

BEP20 Binance Smart Chain Network BSC

0xb78c4cf63274bb22f83481986157d234105ac17e

ERC20 Ethereum Network

0xb78c4cf63274bb22f83481986157d234105ac17e

TRC20 Tron Network

TWGft53WgWvH2mnqR8ZUXq1GD8M4gZ4Yfu
Solana SOL

BEP20 Binance Smart Chain Network BSC

0xb78c4cf63274bb22f83481986157d234105ac17e

SOL Solana Network

FKaPSd8kTUpH7Q76d77toy1jjPGpZSxR4xbhQHyCMSGq
Cardano ADA

BEP20 Binance Smart Chain Network BSC

0xb78c4cf63274bb22f83481986157d234105ac17e

ADA Cardano Network

DdzFFzCqrht9Y1r4Yx7ouqG9yJNWeXFt69xavLdaeXdu4cQi2yXgNWagzh52o9k9YRh3ussHnBnDrg7v7W2hSXWXfBhbo2ooUKRFMieM
Sandbox SAND Decentraland MANA

ERC20 Ethereum Network

0xb78c4cf63274bb22f83481986157d234105ac17e
Algorand ALGO

ALGO Algorand Network

WM54DHVZQIQDVTHMPOH6FEZ4U2AU3OBPGAFTHSCYWMFE7ETKCUUOYAW24Q
Polkadot DOT

DOT Network

13GdxHQbQA1K6i7Ctf781nQkhQhoVhGgUnrjn9EvcJnYWCEd

BEP20 Binance Smart Chain Network BSC

0xb78c4cf63274bb22f83481986157d234105ac17e
Binance

https://pay.binance.com/en/checkout/e92e536210fd4f62b426ea7ee65b49c3

Stars

@juancarlospaco@aguspiza@AndrielFR@S0Sbrigade8@aphkyle@jhgalino@YanMu2020@matkuki@Traumatism@foxoman@whee@bakarilevy@Ryu1845@babaloveyou@jdbernard@cyraxjoe@zendbit@vovavili@xujin8@Geksan@shxdow@singularperturbation@adokitkat@luisacosta828@ByK95@daweedkob@Quantum-Codes@qununc@AriesFoxgirl@Braden-Preston@AriesFoxgirl@mahmoudimus@terretta@AndrewGPU@themorya@zimitz@tommo@rlipsc@jyapayne@barseghyanartur@tiberiuichim@yuchunzhou@lf-araujo@pietroppeter@arkanoid87@jgdevop@onoe-serika@shizhaojingszj@W1M0R@genbtc@buster-blue@Megamegamium@1MarcosDev@lightcax@termermc@catsmells@maleyva1@all-an@janflyborg@smeggingsmegger@ArikRahman@KolyaRS@jinczing@jason-chandler@lolgab@melMass@xgr@majj@dseeni@jmgomez@shaoxie1986@wjl12@cammclain@Optimax125@hanok2@KhazAkar@rxx@FI-Mihej@davidvfx07@gnusec@ziggertonziggy@neroist@Bimzzzzz@tuanductran

cpython's People

Contributors

1marcosdev avatar adokitkat avatar aguspiza avatar all-an avatar andrewgpu avatar andrielfr avatar aphkyle avatar ariesfoxgirl avatar arikrahman avatar arkanoid87 avatar bakarilevy avatar barseghyanartur avatar bimzzzzz avatar braden-preston avatar buster-blue avatar byk95 avatar cammclain avatar catsmells avatar cyraxjoe avatar fi-mihej avatar geksan avatar juancarlospaco avatar khazakar avatar kolyars avatar megamegamium avatar optimax125 avatar quantum-codes avatar ryu1845 avatar traumatism avatar w1m0r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

barseghyanartur

cpython's Issues

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.

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

Reporting a vulnerability

Hello!

I hope you are doing well!

We are a security research team. Our tool automatically detected a vulnerability in this repository. We want to disclose it responsibly. GitHub has a feature called Private vulnerability reporting, which enables security research to privately disclose a vulnerability. Unfortunately, it is not enabled for this repository.

Can you enable it, so that we can report it?

Thanks in advance!

PS: you can read about how to enable private vulnerability reporting here: https://docs.github.com/en/code-security/security-advisories/repository-security-advisories/configuring-private-vulnerability-reporting-for-a-repository

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")

...

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.