Python Speed Question and Opinion
Peter Hickman
peter at semantico.com
Mon Jun 7 09:48:15 EDT 2004
Maboroshi wrote:
> Hi I am fairly new to programming but not as such that I am a total beginner
>
> From what I understand C and C++ are faster languages than Python. Is this
> because of Pythons ability to operate on almost any operating system? Or is
> there many other reasons why?
Although code written in C and C++ may run faster that is rarely the main issue,
you can *write* the code a lot faster in python and have much smaller source
files than in C / C++. Maintaining code written in python is also much easier as
it is generally smaller and clearer. So updating and extending is easier than in
C / C++.
However with pyhon if part of the code is too slow then you can look at coding
just that part in C / C++. A very usfull feature should you need it.
> I understand there is ansi/iso C and C++ and that ANSI/ISO Code will work on
> any system
This is not always the case, they should be portable but in some cases it just
doesn't work that way.
> Also from what I understand there are Interpreted and Compiled languages
> with Interpreted languages memory is used at runtime and Compiled languages
> the program is stored in memory.
>
> Or is this wrong?
There are very few 'pure' interpreted languages. Most modern interpreted
languages compile down to bytecode that is then run on a virtual machine. This
allows for optimisations based on runtime usage ('hotspot' and 'jit' are
keywords in this area) which can significantly reduce the performance gap. Tools
like psyco are available.
> Python is an Interpreted Language, am I right? than wouldn't it be possible
> if there was OS specific Python distrubutions, that you could make Python a
> Compiled language
>
> Or is this completely wrong?
The python executable (python.exe or whatever) is a compiled from C program. The
programs that it runs are interpreted (actually compiled into bytecode and run
on a vm).
If you want pure speed you need assembler! No ifs, ands or buts.
More information about the Python-list
mailing list