Coder Social home page Coder Social logo

py2c's Introduction


WARNING git rebase -i and git push --force may be run on this branch at any point of time because I'm mad and evil!


Py2C

Build Status Coverage Status Gitter Project Status

The project is not functional yet. It's just in pre-alpha/planning stage...

A trans-compiler for compiling Python code into human-readable C++ code, somewhat like what humans might actually write. It would have to be really smart and that's the aim!

I have not been able to find the required amount of time to invest in this project to get it working. And it does not seem likely I will get it in the near future. See #11 for more.

This project is currently focused on statically typed programs and optimizing them. This means the current scope of the project is limited. On some future date, this project may also support all of Python's dynamic nature, subject to whether such a change is helpful and feasible for the project.

The idea is that even in highly dynamic languages (like Python) variables often end up holding (references to) values have only one "type". This is a major area for improving performance as statically typed languages (like C++) often are better with, well, typed variables. So if these one-type variables can be in a faster language, why not have them there?

But for those gains, you'll have to leave the comforts of Python and write C++ code. And here's where Py2C is supposed to come in! You can just tweak the existing Python code a bit and pass it through Py2C and it automagically outputs C++ code that does that same thing as the Python code, just a whole lot faster! Yay!

Here's Py2C in action (rather Py2C's planned action) on "Hello World!":

print("Hello World!")

The above should compile to something like:

#include <iostream.h>

int main() {
   std::cout << "Hello World!\n";
   return 0;
}

If it is needed, a special header file is included in the generated file. For example, the above example would compile to something like:

#include "py2c.h"

int main() {
    py2c::print(py2c::str("Hello World!"));
    return 0;
}

If all goes as planned, on one fine day, Py2C will also be extendable to accommodate for API changes across the languages, for third party packages (like NumPy, Qt etc)

py2c's People

Contributors

pradyunsg avatar

Watchers

 avatar

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.