Id go this way too. Basic C is straightforward. I usually consider learning a new "thing " if the time to support potwntially combersome solution using existing methods justifies the effort.
On Jan 23, 2018 09:01, "Ned Batchelder" <n...@nedbatchelder.com> wrote: > On 1/23/18 8:48 AM, kushal bhattacharya wrote: > >> On Tuesday, January 23, 2018 at 7:05:02 PM UTC+5:30, bartc wrote: >> >>> On 23/01/2018 13:23, kushal bhattacharya wrote: >>> >>>> On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal >>>> bhattacharya wrote: >>>> >>>>> Hi, >>>>> Is there any python framework or any tool as which can generate C >>>>> code from python code as it is . >>>>> >>>>> Thanks, >>>>> Kushal >>>>> >>>> yes i have but it generates a complex C code with python dependencies.I >>>> want to call the generated function from another C code but i Cant figure >>>> out how to do that >>>> >>> Because the translation isn't simply defined. >>> >>> I've just tried nuitka on the Python code 'a=b+c', and it generates 2400 >>> lines of C. The main purpose seems to be to generate a self-contained >>> executable corresponding to the Python, but generating first a C >>> equivalent then using a C compiler and linker. >>> >>> This equivalent code may just contain all the bits in CPython needed to >>> do the job, but bypassing all the stuff to do with executing actual >>> byte-code. But it also seems to do some optimisations (in the generated >>> C before it uses C compiler optimisations), so that if static types can >>> be inferred it might make use of that info. >>> >>> Perhaps you simply want to use Python syntax to write C code? That would >>> be a different kind of translator. And a simpler one, as 'a=b+c' >>> translates to 'a+b+c;' in C. >>> >>> -- >>> bartc >>> >> >> This is exactly what i meant to say.My goal is to translate the python >> code into its C equivalent with function name as it is. >> > > The best way to do that is to read the Python code, understand what it > does, and re-write it in C. You won't find an automatic tool that can do > the job you want. The semantics of Python and C are too different. > > --Ned. > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list