Python for air traffic control?

Chris Barker chrishbarker at home.net
Thu Jul 5 13:49:01 EDT 2001


Russ wrote:

> I have done real-time programming in C++, and I used static or
> start-up memory allocation almost exclusively to avoid memory
> management overhead. It really helps execution efficiency, but it
> really sucks up memory. Memory is cheap these days, however. I would
> probably take the same approach in Python, if possible. (As I said, I
> am a Python beginner.)

I was waiting for someone with better understanding of Python internals
to address this, but since no one has...

Using static memory allocation with Python is impossible, and start-up
allocation would be very difficult, if not imposible. This is because of
Python's immutable types: a simple expression like:

i = i+1  (or I += 1, but I don't want to get into that!)

Creates a new number, and assigns it to the name, i. It does not change
the data at the address refered to bye the original i. This means that
you will be dynamically allocating memory almost constantly! 

You may want to consider looking into the Numeric module as well, the
Numeric Array type gives you the option of storing a bunch of numbers in
a pre-assigned array, so that:

A[i] = A[i] + 1  does, in fact, change the value at the same address,
but it also creates an intermediate value first. (A[i] += 1 does not)
You can also use this kind of notation:

add(A[i],1,A[i])  : the second A[i] tells the add function where you
want to store the result.

(python gurus: I suspect I have this at least a little wrong, please
feel free to correct me)

Anyway, what this tells you is that if you want statically allocated
memory with Python, you will have a very hard time enforcing it (if it
can be done at all) and, in fact, end up using a subset of Python, which
is not really Python at all.

In short: if you want a statically allocated, strongly typed language
with type chaecking before run time, you don't want Python. I think many
of us feel that those features are not required for mission critical
applications, but if you do, you need to find another language!

Another note, with all the disagrement in this thread, it's interesting
that no one seems to think that c/C++ would be a good choice either!

-Chris

-- 
Christopher Barker,
Ph.D.                                                           
ChrisHBarker at home.net                 ---           ---           ---
http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                   ------@@@     ------@@@     ------@@@
Oil Spill Modeling                ------   @    ------   @   ------   @
Water Resources Engineering       -------      ---------     --------    
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------



More information about the Python-list mailing list