[Tutor] Has anyone ever tried to convert the textual output of the dis module to another language

Max Noel maxnoel_fr at yahoo.fr
Sun Apr 17 18:12:39 CEST 2005


On Apr 17, 2005, at 16:51, Sean Perry wrote:

> R. Alan Monroe wrote:
>> Just curious. Googling for 'python "dis module" convert "another
>> language" ' only got two hits. So maybe no one is trying it? I was
>> just daydreaming about a native python compiler, and wondered how
>> feasible it would be.
>
> There is already a python -> exe converter. Comes up on the list now 
> and then. What would your idea change?

	A lot. py2exe doesn't compile anything. Basically, all it does is 
bundle a Python interpreter and the code in a clickable application so 
that people can run it without having Python installed. As you've 
probably noticed, a py2exe program runs at the exact same speed as that 
same program run with the Python interpreter from the command line.
	Natively compiling a Python program should theoretically yield a 
tremendous increase in execution speed (as in "faster than psyco"), at 
the expense of cross-platformness (you can only run your binary on the 
platform for which it was compiled).

	Honestly, I don't think that'd be useful. I'm no expert on this 
matter, but I know that coding a compiler is an extremely long and 
difficult process, especially when you're dealing with a dynamic 
language like Python. Also, early versions of a compiler are slow, and 
optimizing it is another extremely long and difficult process.
	Witness gcc -- the C language has been around for 30 years, the most 
widely used for 20, the gcc effort is at least 15 years old, yet 
they're still finding ways to make it spit out faster code...
	Which leads me to my next point: if you want your Python program to be 
faster, rewrite the speed-critical parts (there aren't that many of 
them) in C. That way, you can take advantage of 15+ years of compiler 
optimization efforts.

-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting 
and sweating as you run through my corridors... How can you challenge a 
perfect, immortal machine?"



More information about the Tutor mailing list