[Tutor] where python is used in real world

Steven D'Aprano steve at pearwood.info
Sun Dec 4 23:31:53 CET 2011


surya k wrote:
> I don't understand why python doesn't provide executable files for the
> source code.

I am afraid that you are confused. Python source code *are* executable. They
would hardly be *programming* code if you can't execute them.

They're just not stand-alone executable. They require a virtual machine
environment to execute, just like Flash, .Net, Java, Javascript, Perl, PHP,
.ASP, and hundreds of other languages.

> I am using py2exe for building executables and I found that, it doesn't
> completely change code into binary but creates dll files and python
> libraries to run that particular code. This process makes program very
> large although it isn't.

I am afraid you are again working under a misunderstanding. The program *is* 
very large because most of the "smarts" is in the virtual machine environment. 
The source code on its own is small, but it doesn't do anything without the 
environment.

Again, this is how Java works, and .Net, and Flash, to say nothing of other 
languages. The Java Runtime Environment (JRE) for Java 5 is 15 MB; the .Net 
3.5 runtime is 197 MB. A small py2exe bundle is 6 MB.


Python offers a rich, safe environment for the programmer, and that requires a 
rich, complex feature set. Programming in Python isn't just flipping bits and 
adding numbers. That requires a large infrastructure to support it. In 1984 
the Macintosh API was maybe 100 functions; today, plain Python is probably 
fifty times larger than that, and if you add graphics perhaps 500 times 
larger. Do you think you get this code for free? It has to be *somewhere*.


> 1. Why doesn't python doesn't offer executable file ? 

If you mean a stand-alone, minimal application like you used to get back in 
1980 when hand-coding the absolute least amount of C or Pascal code that could 
be compiled to do the job, well, that's a hard thing to do, and it is 
unnecessary, so it doesn't get done.


> 2. If one wants to
> make a commercial software using python, how can he hide the code?

There is lots of commercial code which is open source. Just ask Ubuntu and Red 
Hat for starters.

Why do you want to hide the code? What are you afraid of?

Tell us what your fear is, and we can perhaps help you.


> However, if one wants to make an open source software, as python doesn't
> offer executable files, how people make those so as to distribute their
> products to people?

You just make the Python runtime environment a requirement, exactly as people 
do with other languages.




-- 
Steven



More information about the Tutor mailing list