Code Monkey home page Code Monkey logo

py2c's People

Contributors

pradyunsg 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  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

py2c's Issues

Clarify that you mean C++

A common mistake is to say C/C++ when you talk about these two languages.

Not only is this correct, it also implies that they're the same language (they're not).

For example, the sample code you've posted on the main page (the hello world program converted to C++) can't compile on C because it doesn't support the << operator (it only supports printf).

Not only that, in addition to the futures that were introduced in C++ only existing in that language (ie, classes, templates, exception handling, etc.), there's certain code that would compile on C but not on C++, like this:

int main()
    {
        double sq2 = sqrt(2);   /* Not C++: call undeclared function */
        int s = sizeof('a');    /* silent difference: 1 in C++ sizeof(int) in C */
    }

And this:

void* malloc(size_t);

void f(int n)
{
    int* p = malloc(n*sizeof(char));  /* not C++. In C++, allocate using `new' */
    char c;
    void* pv = &c;
    int* pi = pv;   /* implicit conversion of void* to int*. Not in C++ */
}

(both are taken from Stroustrup (the original designer of C++)'s website.)

Sources:

http://www.stroustrup.com/bs_faq.html#C-is-subset

http://www.stroustrup.com/bs_faq.html#C-slash

Proposal: Using codegen package adapted for C++

Hi,

I tried to adapt codegen which is Python -> ast.AST -> Python to generate C++ in the last step. And it roughly works 😄. It is here.

Using it should look like :

import ast
import codegen_cpp

py_code = """
s = 10
s = s + 5
"""

node = ast.parse(py_code, mode='exec')
cpp_code = codegen_cpp.to_source(node)

print( py_code, "\n----------------------\n")
print(cpp_code , "\n----------------------\n")

is this project discontinued?

I like the Idea behind this project, But seeing it not even pass the prototype stage even after 4 years is not good sign. So will this project ever be usable? or Did you just leave it?

Import error in /py2c/translator.py

On line 26 of /py2c/translator.py it says:

from py2c.syntax_tree import python

When I attempted to run the file, it said:

>>> 
Traceback (most recent call last):
  File "C:\Users\Daniel\Desktop\Py2C-master\py2c\translator.py", line 26, in <module>
    from py2c.syntax_tree import python
ImportError: cannot import name 'python'
>>> 

It seems to be trying to import python.ast and failing. I have no idea what the proper method of loading it is, though appearently it is not import.

If anyone knows how to deal with this, I'd be happy to fix it.

a long way to go

Hi there,
As one of many guys out there who loves python and would appreciate an automated way to transform prototyped python code into readable C++ I must say this project is far from usable. And at this stage you should ask yourself, is it worth the troubles in the long run?

The goal seems to be a conversion which does not facilitate the Python API in any way to be as fast as possible and creates readable code.

Both Shed Skin and Nuitka create C++ code. The former in a almost readable form (quite close to python code with many library calls and defines) but with some restrictions, while the latter is CPython feature complete and has ambitions for speed ups.

IMO, Shed Skin is amazing and the readability might improve in future versions.
Nuitka on the other hand takes the performance path, which is already well served with Cython and JITs. I say only humans are able to to write code that is readable and high(est) performance at the same time. So better join up with Shed Skin, or Nuitka.

command line usage syntex error

Hi,
when I try to convert python code to c on windows with python file placed in same location where py2c.sh exists. I get an error running the following command

py2c -o file Encoder.py --keep
error

'py2c' is not recognized as an internal or external command,
operable program or batch file.

I get same error even if I run
py2c.sh -o file Encoder.py --keep

How to convert?

I don't know how to actually USE Py2C to convert Python into C/C++. What specific function do you use in the py2c folder to convert the code?

[meta-issue] Progress Tracker

This is a meta-issue for tracking the progress of the project till it's first public release.
I'll keep posting updates here.

  • Make a clear plan of Action for the project. (Replace this list)
  • Create a (high-level) list for things to be done. Add items to it when you get to an item.

Running Translation

Hi,

Would you please tell me how can I run Py2C after install? I couldn't find anything that could help me with this.

I'd happy to make an online demo for Py2C if you like.

Guiding some students to contribute

I would like to guide some students to contribute to this project and would like to get your inputs on the priorities you might have.

Thanks!

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.