Why Not Translate Perl to C

Oleg Broytmann phd at phd.fep.ru
Sat Jun 30 13:30:21 EDT 2001

On Sat, 30 Jun 2001, Levente Sandor wrote:
> In article <mailman.993895305.13072.python-list at python.org>, Oleg Broytmann
> says...
> >   This is about Perl, but it applies to Python as well. And of course not
> >only to C, but to native code too.
> >
> >http://www.perl.com/pub/a/2001/06/27/ctoperl.html
> >
> >   "A C program to do what your Perl program does would have to do most of
> >the same things that the Perl interpreter does when it runs your Perl
> >program. There is no reason to think that the C program could do those
> >things faster than the Perl interpreter does them, because the Perl
> >interpreter itself is written in very fast C."
> I think there is a very serious reason to think that. Of course, calling a C
> function from an interpreted language isn't significantly slower than doing the
> same thing in machine code. But just compare some "pure" Python functions or
> loops to their C equivalents.
> "4.7 cStringIO -- Faster version of StringIO
> The module cStringIO provides an interface similar to that of the StringIO
> module. Heavy use of StringIO.StringIO objects can be made more efficient by
> using the function StringIO() from this module instead."
> (From the Python Library reference)

   Yes, but you cannot write a compiler that will translate StringIO into
cStringIO. Python is too dynamic for this. If Python will ever get static
typing, things will become much better and we can return to the task of
building a compiler.

     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

More information about the Python-list mailing list