[Tutor] where python is used in real world

Alan Gauld alan.gauld at btinternet.com
Sun Dec 4 15:01:54 CET 2011


On 04/12/11 07:47, surya k wrote:
> I don't understand why python doesn't provide executable files for the
> source code.

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

Because python is an interpreted language like Java, early Visual Basic 
and many other languages. It would be difficult to build a true native 
machine code compiler for Python and still retain the features that make 
it so productive. Some partial compilers exist but they cannot cover all 
of the features of the language. As programmers we have to make the 
trade-off of speed of development versus speed of execution, memory 
usage, ease of deployment and many other factors. This is what engineers 
do in any type of engineering, software engineering is no different. 
It's all about choosing the most appropriate compromise for the problem 
at hand.

> 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.

Define large?
It's not usually very large compared to things like Microsoft Office or 
even single applications like Photoshop. Compare the size of Visio 
against the Python open source equivalent: Dia.

And remember that if you had to code up in C all the things you get as 
part of the Python language your short program would be much much 
bigger. A program's real size is determined by the functions it performs 
not the number of lines of source code. (If you want an objective 
measure calculate the Function Point metric) So yes, for trivial 
programs Pythons overheads will be higher than, say , C. But for real 
world applications the differences will be much less, and Python will 
often be smaller. And if the Python interpreter is already installed 
even small apps become comparable.

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

Use py2exe...  Or only deploy the compiled modules (.pyc)  or rely on a 
license agreement and the threat of litigation. Is hiding the source
code a necessary thing? For many years it was common for commercial 
applications to come with the source code. In fact the very first PC 
that I used came with a manual containing the full assembler listing of 
the BIOS... It is a relatively modern idea that we should try to hide 
how our code works from the userts. And it is mainly paranoia that makes 
us think that not shipping source code makes our programs "safe" from 
copying. It is the ideas and concepts of code that need protecting - via 
patents - not the source. Just compare how many office apps are out 
there. Very similar to use but very different source code. Its easy to 
recreate a feature once you see how it works. Hiding the source makes 
very little difference and provided you have legal protection
you can sue anyone who steals your code - after all they will have the 
same difficulty!

> 3. 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?

Just take a look at the many open source applications written in Python.
Essentially its the same as applications written in Java or .NET. The 
user has to install the execution environment ass wekl as the app. But 
they only need to do it once. And in Linux and MacOS Python is already 
installed alongside Java and Perl etc.

But we have already given you all of this information in replies to your 
previous post on the same theme a few days ago.

And to pick up on your subject line, Python is used extensively in "the 
real world" in many areas outside of developing shrink-wrapped 
commercial applications. If you are writing bespoke code for a contract 
then the client will expect you to provide the source code as normal 
practice. And provided the app does what was asked and runs quickly 
enough they are unlikely to care that it was written in Python (in 
factthey may prefer it since Python is comparatively easy to maintain). 
Similarly. Python is used in many large scale IT operations to provide 
support and test tools (Google being a good example) or for rapid 
prototyping.

You can find many examples of real-world Python on the Python.org 
website, just look under success stories:

http://www.python.org/about/success/

And browse the job adverts...

http://www.python.org/community/jobs/

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list