Pytocpp: A toy transpiler from a subset of Python to C++

Ever since i have started working with python, there has been one thing that has been bugging me: Pythons performance. Of course, Python is an interpreted language and dynamically typed, so the slow performance is the result of those features, but I have always been wondering if simply embedding a minimal python runtime environment, adapted to the given program into an executable with the program itself would be feasible. Well… I think it is.

What my project does

What the pytocpp Python to C++ Transpiler does is accept a program in a (still relatively simple) subset of python and generate a fully functional standalone c++ program. This program can be compiled and ran and behaves just like if it was ran with Python, but about 2 times faster.

Target audience

As described in the title, this project is still just a toy project. There are certainly still some bugs present and the supported subset is simply too small for writing meaningful programs. In the future, I might extend this project to support more features of the Python language.

Comparison

As far as my knowledge goes, there are currently no tools which are able to generate c/c++ code from native python code. Tools like Cython etc. all require type annotations and work in a statically typed way.

The pytocpp github project is linked here

I am happy about any feedback or ideas for improvement. Sadly, I cannot yet accept contributions to this project as I am currently writing a thesis about it and my school would interpret any foreign code as plagiarism. This will change in exactly four days when I will have submitted my thesis :).

submitted by /u/B3d3vtvng69 to r/Python
[link] [comments]


Commentaires

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *