473,322 Members | 1,755 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,322 software developers and data experts.

Compiler C or Python?

On Tue, Aug 26, 2003 at 04:33:17PM -0500, Jeff Epler wrote:
4. It's possible to write code so that __import__ uses compiler.compile
instead of the written-in-C compiler, but I don't have this code handy.
Also, a test suite is needed, and presumably a written-in-C implementation
as well. (option 2: make the compiler.compile interface the standard
compiler, and let the builtin compiler support a Python subset
sufficient to bootstrap the written-in-python compiler, or arrange
to ship .pyc of the compiler package and completely get rid of the
written-in-C compiler)


Could you make an effort to locate that code, or give some suggestions to
where I might locate it myself?

And in general, if should want to alter the Python compiler, should I start
with the Python or C version?
As far as I can see from your email the Python version is easier to modify,
but why two compilers? Isn't that a lot to maintain?

Sincerely
Jørgen

Jul 18 '05 #1
4 2294

"Jørgen Hermanrud Fjeld" <jh*@hex.no> wrote in message
news:ma**********************************@python.o rg...
On Tue, Aug 26, 2003 at 04:33:17PM -0500, Jeff Epler wrote:
4. It's possible to write code so that __import__ uses compiler.compile
instead of the written-in-C compiler, but I don't have this code handy.
Also, a test suite is needed, and presumably a written-in-C implementation
as well. (option 2: make the compiler.compile interface the standard
compiler, and let the builtin compiler support a Python subset
sufficient to bootstrap the written-in-python compiler, or arrange
to ship .pyc of the compiler package and completely get rid of the
written-in-C compiler)


Could you make an effort to locate that code, or give some suggestions to
where I might locate it myself?

And in general, if should want to alter the Python compiler, should I start
with the Python or C version?
As far as I can see from your email the Python version is easier to modify,
but why two compilers? Isn't that a lot to maintain?

[John Roth]
I believe that the Python version of the compiler uses the C version
in several places. The documentation mentions the parser and the
creation of the concrete syntax tree.

In other words, it's not a complete implementation. It also seems
to have some problems with error checking. The primary use seems
to be manifesting an abstract syntax tree for program analysis tools
to work on.

John Roth

Sincerely
Jørgen
Jul 18 '05 #2
jh*@hex.no (Jørgen Hermanrud Fjeld) writes:
On Tue, Aug 26, 2003 at 04:33:17PM -0500, Jeff Epler wrote:
4. It's possible to write code so that __import__ uses compiler.compile
instead of the written-in-C compiler, but I don't have this code handy.
Also, a test suite is needed, and presumably a written-in-C implementation
as well. (option 2: make the compiler.compile interface the standard
compiler, and let the builtin compiler support a Python subset
sufficient to bootstrap the written-in-python compiler, or arrange
to ship .pyc of the compiler package and completely get rid of the
written-in-C compiler)
Could you make an effort to locate that code, or give some suggestions to
where I might locate it myself?

And in general, if should want to alter the Python compiler, should
I start with the Python or C version?


Whichever's easiest :-) This is usually the Python one.

A toy that might come in handy is an interactive mode (based on
code.InteractiveConsole) that compiles input with the customized
compiler.
As far as I can see from your email the Python version is easier to
modify, but why two compilers? Isn't that a lot to maintain?


The Lib/compiler/ package is pretty slow. Also, making that the only
compiler might lead to irritating bootstrapping problems (which I now
see Jeff talked about...).

Cheers,
mwh

--
Do I do everything in C++ and teach a course in advanced swearing?
-- David Beazley at IPC8, on choosing a language for teaching
Jul 18 '05 #3
On Tue, Sep 02, 2003 at 11:37:03AM +0000, Michael Hudson wrote:
jh*@hex.no (Jørgen Hermanrud Fjeld) writes:
And in general, if should want to alter the Python compiler, should
I start with the Python or C version?
Whichever's easiest :-) This is usually the Python one.

Then I shall start with that one. Are there any other arguments/reasons to
choose one or the other? That is technicalities one should consider.
A toy that might come in handy is an interactive mode (based on
code.InteractiveConsole) that compiles input with the customized
compiler.

Thanks, this can make the task at hand a lot easier.
As far as I can see from your email the Python version is easier to
modify, but why two compilers? Isn't that a lot to maintain?


The Lib/compiler/ package is pretty slow. Also, making that the only
compiler might lead to irritating bootstrapping problems (which I now
see Jeff talked about...).

Yes, but the code it generates will be fast enough for my purposes.
Do you happen to know how consistency between the compilers is maintained?

Sincerely
Jørgen

Jul 18 '05 #4
jh*@hex.no (Jørgen Hermanrud Fjeld) writes:
On Tue, Sep 02, 2003 at 11:37:03AM +0000, Michael Hudson wrote:
jh*@hex.no (Jørgen Hermanrud Fjeld) writes:
And in general, if should want to alter the Python compiler, should
I start with the Python or C version?
Whichever's easiest :-) This is usually the Python one.

Then I shall start with that one. Are there any other arguments/reasons to
choose one or the other? That is technicalities one should consider.


I don't think so. The code they produce is essentially identical,
AFAIK (the only difference I'm aware of is the ordering of the
constants in co_consts -- hardly critical).

Oh, Raymond Hettinger added some bytecode rewriting steps to the C
compiler in 2.3. I don't think Lib/compiler does these.

For *very* simple tweaks I sometimes find Python/compile.c easier to
work with, but that's probably because Python/compile.c is a hunk of
procedural C code I've worked with a fair bit and Lib/compiler is an
OOP-y framework-y hunk of code I don't quite understand. Someone
starting from scratch is unlikely to find this.

Obviously, Python/compile.c gets more testing, and probably has fewer
bugs.
As far as I can see from your email the Python version is easier to
modify, but why two compilers? Isn't that a lot to maintain?


The Lib/compiler/ package is pretty slow. Also, making that the only
compiler might lead to irritating bootstrapping problems (which I now
see Jeff talked about...).

Yes, but the code it generates will be fast enough for my purposes.


Oh yes, the compiled code runs at the same speed.
Do you happen to know how consistency between the compilers is
maintained?


Blood and toil :-/

Cheers,
mwh

--
I have long since given up dealing with people who hold idiotic
opinions as if they had arrived at them through thinking about
them. -- Erik Naggum, comp.lang.lisp
Jul 18 '05 #5

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

Similar topics

2
by: Jeff Epler | last post by:
Hello. Recently, Generator Comprehensions were mentioned again on python-list. I have written an implementation for the compiler module. To try it out, however, you must be able to rebuild...
12
by: rhmd | last post by:
Just found Python and I love it. What an elegant language! I would like to use it for various applications, but the mathematical calculations are way too slow (a million sines 8 seconds in Python...
3
by: dbrown2 | last post by:
I'm trying to understand and document how to install pypar on Win2k. Pypar needs to be installed with some MPI library code and also needs libpython23.a and other files which are not included with...
188
by: Ilias Lazaridis | last post by:
I'm a newcomer to python: - E01: The Java Failure - May Python Helps? http://groups-beta.google.com/group/comp.lang.python/msg/75f0c5c35374f553 - I've download (as suggested) the python...
14
by: Mark Dufour | last post by:
After nine months of hard work, I am proud to introduce my baby to the world: an experimental Python-to-C++ compiler. It can convert many Python programs into optimized C++ code, without any user...
48
by: meyer | last post by:
Hi everyone, which compiler will Python 2.5 on Windows (Intel) be built with? I notice that Python 2.4 apparently has been built with the VS2003 toolkit compiler, and I read a post from Scott...
2
by: Michael Hudson | last post by:
The PyPy development team has been busy working and we've now packaged our latest improvements, completed work and new experiments as version 0.9.0, our fourth public release. The highlights of...
31
by: Mark Dufour | last post by:
Hi all, I have recently released version 0.0.20 and 0.0.21 of Shed Skin, an optimizing Python-to-C++ compiler. Shed Skin allows for translation of pure (unmodified), implicitly statically typed...
1
by: Orestis Markou | last post by:
On Tue, Oct 7, 2008 at 5:39 PM, Terry Reedy <tjreedy@udel.eduwrote: The ast module is indeed very different from the compiler package, as it depends on the exact grammar definition that the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.