Hi, just got this back as a reply from the author of a GCC Python frontend. This project flew completely below my radar so far, even though it's the second GSoC being invested here. From the Python wiki page, it looks like static Python compilers are starting to sum up these days. IMHO, it would be better to get these consolidated a bit, rather than having people reinvent wheels all over the place. http://wiki.python.org/moin/PythonImplementations Stefan -------- Original-Message -------- Subject: Re: GCC Python FE From: Philip Herron <herron.philip (at) googlemail.com> On 3 July 2011 16:57, Stefan Behnel wrote:
I just stumbled over this wiki page:
http://gcc.gnu.org/wiki/PythonFrontEnd
I'm a Cython core developer, and as such, I wonder what the purpose of this project was, and what it lead to.
Well i was inspired by PHC http://www.phpcompiler.org/ which was a similar idea but for php, the purpose was mostly i though it was interesting and wanted to see how feasible it is to do something like this plus i wanted to learn more, i've written compilers for simple more static languages and made my own interpreter before and the buzz word at the moment seems to be jit compilers but i still think compiling like this could still be a good step forward at least for my understanding. And in the end it could possibly open up different opportunities to use python in a different way be it on low memory systems or even a different way of embeding python into programs but we will see how feasible that is when its more mature. Well last year gsoc 2010 i spent mostly figuring out how i was going to implement a lot of things and getting more comfortable with GCC internals. But i am currently doing this for gsoc 2011 again http://www.google-melange.com/gsoc/project/google/gsoc2011/redbrain1123/1100...
The project is marked as "part of GSoC 2010", so I guess there was some kind of outcome. Could you give me an idea of how it went and what was achieved?
Well from last year's Gsoc i successfully got dynamic typing working, but its mostly similar to how cython does it, by wrapping things into the py_obect_ type where it stores the data and has hooks to its binary protocol and other standard hooks like print and destory etc or whatever it is, haven't looked at the cython code in sometime. Dynamic typing is kind of handled at runtime still because i cant really avoid it, but i am happy that i am working on a constant folding pass because i cant rely on gcc's own constant folding code to handle this because i have to handle it in my own front-end IL. But besides that i am working on object orientation and calls at the moment. Where i take something like: class foo: def __init__ (self) self.x = 1 And have to generate the type then generate the methods like: struct main.foo { gpy_object_t * x; } gpy_object_t * main.foo.__init__ (struct main.foo * self) { self->x = fold_int (1); ... } So i am just wrapping it into a normal object like you would in any other language because its fairly trivial its awkward in that python you can do self->x where x wasn't pre-declared it seems so i have to iterate several passes over my IL so i can generate the type then generate the methods. But this is all currently being worked on its mostly done just cleaning up lots of code and fixing some bugs leaving polymorphism for now will work on it when i come to it but i am more worried about how i will get calls working and imports across multiple files. But i am planning on using GCC's LTO to help me get around that, since at link time i have the opportunity to see code from everywhere to figure out where calls should be placed etc. But i wont get time to work on that for a few weeks yet as i need to finish what i am doing first. I am fairly happy with what i have achieved so far as its a lot of work for me on my own to do in 2 summers although i spent a lot of time though my university work just thinking how i will make things work so i can concentrate on implementation now. Its mostly a passion of mine but in the end i just want to understand things more and it seems this has taught me alot of how dynamic languages work and i enjoy it so i keep working on it. Although university is nearly over so i guess i will need to find a job xD lol. Hope this answers your questions feel free to ask more if your interested. :) --Phil
participants (1)
-
Stefan Behnel