Python compiler?
Rainer Deyke
root at rainerdeyke.com
Wed Apr 18 00:23:56 EDT 2001
"news-server.columbus.rr.com" <antediluvianistic at columbus.rr.com> wrote in
message news:gz3D6.111321$BB5.897657 at typhoon.columbus.rr.com...
> Has everyone contemplated upon creating a python 'compiler', which can
> produce a self-contained binary executable?
import os
name = argv[1]
outfile = open('%s.c' % name, 'w')
infile = open('%s.py' % name, 'r')
outfile.write("""
#include "Python.h"
int main()
{
Py_Initialize();
PyRun_SimpleString(%s)
Py_Finalize();
return 0;
}
""" % infile.read())
infile.close()
outfile.close()
system('gcc -o %s %s.c' % (name, name))
> (for when speed is an absolute
> neccessity)
A self-contained executable is no guarantee of speed. I recently found that
even with extensions(*) in C++ (with Boost.Python), Python is too slow for
my own current game project. I've since converted all of the Python code in
that project to C++.
*: There is a possibility that the real culprit was the binding between C++
and Python. There is also the possibility that reshuffling some code to or
from the extension modules would have allowed me to keep using Python. I
decided not to risk it; it only took three days to convert the Python code
to C++.
--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games - http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor
More information about the Python-list
mailing list