473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Does the world need another v0.1 python compiler?

I'm feeling a little guilty here. I spent a lot of my free time last year
working on an x86 compiler for python. I made a reasonable amount of
progress, but my interests wandered off into other areas. I basically just
got bored and stopped working on the thing maybe 6 months ago. So today, I
went to the directory that contains all of my source checkouts, and saw this
v 0.1 compiler just sitting out there AGAIN.

It's not that I don't want to release the code, but it's just not in quite
good enough shape to just throw out there and hope that other people pick up
and get things working. I've seen more than a few half-assed compiler
implementations out there and part of me thinks I'd just be wasting my time
by just zipping up what I have and throwing it out there. Also, I don't
really expect any significant speed increases, which seems to be what people
want out of a compiler, but was primarily interested in creating standalone
..exes without the need for a 'runtime environment' (whatever that means).
There might be a little speed increase from unrolling the eval loop, but
nothing too serious.

The basic approach I took was compiling to bytecode, and then
transliterating python bytecode to x86 asm. And it is working a little bit.
There is a slightly modified version of the CPython interpreter that
introduces xfunction and xcode objects, that basically act the same as
function and code objects, but run native code. I've successfully generated
some very simple .pyds that can be imported into this interpreter. I also
have some tests that test each bytecode on a small scale and they all seem
to be working. I can just barely run pystones. The biggest problem right
now seems to be that reference counting isn't adding up, resulting in some
serious performance degradation.

On the downside, right now it's Windows only. There's nothing inherently
windows specific, but I don't have anything to build on other platforms. It
also assumes you've got the visual studio toolchain.

So like I said, I feel a little guilty about keeping this thing hostage on
my systems at home. On the other hand, if anyone else is interested,
they're going to need to be a VERY early adopter.

Does anyone have any serious interest in taking a look?

-Grant

Feb 8 '07 #1
5 1546
Grant Olson wrote:
The basic approach I took was compiling to bytecode, and then
transliterating python bytecode to x86 asm. And it is working a little bit.
An interesting option might be to generate the byte code used by
the SpiderMonkey engine in Mozilla. That's used to handle both
Javascript in Firefox and ActionScript in Flash. It has a just-in-time
compiler, so you get x86 machine code when you need it.
And the run time engine is tiny; there's a copy inside Flash, which is
only 2MB.

That could be a way to get a faster Python without bringing excess
baggage.

John Nagle
Feb 8 '07 #2
On 8 Feb., 17:00, John Nagle <n...@animats.comwrote:
Grant Olson wrote:
The basic approach I took was compiling to bytecode, and then
transliterating python bytecode to x86 asm. And it is working a little bit.

An interesting option might be to generate the byte code used by
the SpiderMonkey engine in Mozilla. That's used to handle both
Javascript in Firefox and ActionScript in Flash. It has a just-in-time
compiler, so you get x86 machine code when you need it.
And the run time engine is tiny; there's a copy inside Flash, which is
only 2MB.

That could be a way to get a faster Python without bringing excess
baggage.

John Nagle
This code generation for an arbitrary backend sounds more like an
appropriate task for PyPy. I think Grant's or anyone elses compiler
could be a viable tool for augmenting the CPython interpreter in
particular in the presence of optional type annotations in Py3K.

Feb 8 '07 #3
On Feb 8, 8:03 am, "Kay Schluehr" <kay.schlu...@gmx.netwrote:
This code generation for an arbitrary backend sounds more like an
appropriate task for PyPy. I think Grant's or anyone elses compiler
could be a viable tool for augmenting the CPython interpreter in
particular in the presence of optional type annotations in Py3K.
IMHO, with the presence of static types in Py3K, we should have a
static compiler that can be invoked dynamically, just like Common
Lisp.

Something like

def foo(...):
bar = static_compile(foo, optimize=2)
bar(...)

JIT compilers are hyped, static compilers perform much better. This
way the programmer can decide what needs to be compiled. This is the
reason why CMUCL can compete with most C compilers.



Feb 8 '07 #4
sturlamolden:
IMHO, with the presence of static types in Py3K, we should have a
static compiler that can be invoked dynamically, just like Common
Lisp.
Something like

def foo(...):
bar = static_compile(foo, optimize=2)
bar(...)

JIT compilers are hyped, static compilers perform much better. This
way the programmer can decide what needs to be compiled. This is the
reason why CMUCL can compete with most C compilers.
Lot of Python code uses Psyco, so maybe it may be better to extend
Psyco to that 'static compilation' functionality too:

def foo(...):
psyco.static_bind(foo)

At the moment I think this approach can't improve much the speed of
Python programs compared to what Psyco is already able to do.
PyPy's RPython and ShedSkin are also to be considered, recently
ShedSkin is going to support some of the usual Python forms of lazy
processing too.

Bye,
bearophile

Feb 8 '07 #5
On Feb 8, 7:02 pm, bearophileH...@lycos.com wrote:
At the moment I think this approach can't improve much the speed of
Python programs compared to what Psyco is already able to do.
Pyrex generates code that competes with hand-written C. It is as close
to statically typed Python as it gets.

http://www.scipy.org/PerformancePython

Feb 8 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Christian Tismer | last post by:
Dear Python community, since I didn't get *any* reply to this request, either the request was bad or there is really nobody using f_tstate in a way that makes it urgent to keep. I will wait a...
7
by: Rene Pijlman | last post by:
Section 6.5 "What is delegation?" of the FAQ says: "Python programmers can easily implement delegation. For example, the following class implements a class that behaves like a file but converts...
8
by: Will | last post by:
I just discovered Python and looked briefly at one of the tutorials for beginners... It looks a lot like the old Command line Basic... I'm sure it does much more but... 1 - Can you create...
30
by: Christian Seberino | last post by:
How does Ruby compare to Python?? How good is DESIGN of Ruby compared to Python? Python's design is godly. I'm wondering if Ruby's is godly too. I've heard it has solid OOP design but then...
5
by: MC | last post by:
Hi If I have a pointer to a some structure say for example payroll_ptr where struct payroll { ... } has some members and if i use a function argument as int function_process ( (payroll_ptr)...
75
by: Beni | last post by:
I have been programming in C for about a year now. It sounds silly, but I never took the time to question why a C(or C++ or Java) program execution begins only at the main(). Is it a convention or...
13
by: Chris Seymour | last post by:
HI All, Does such a beast exist? Have been looking but haven't seen any. Any insight would be appreciated. Thanks. Chris
113
by: John Nagle | last post by:
The major complaint I have about Python is that the packages which connect it to other software components all seem to have serious problems. As long as you don't need to talk to anything outside...
162
by: Sh4wn | last post by:
Hi, first, python is one of my fav languages, and i'll definitely keep developing with it. But, there's 1 one thing what I -really- miss: data hiding. I know member vars are private when you...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.