Python for air traffic control?
Carlos Ribeiro
cribeiro at mail.inet.com.br
Tue Jul 3 18:27:29 EDT 2001
Many of the concerns raised on the group are related to memory-related
problems: allocation/deallocation and garbage collection, which can be an
plentiful source of bugs. I have some specific suggestions to deal with
them, which may or not be applicable in your case.
- You can avoid allocation/deallocation in some languages by using static
structures, or by preallocating as much memory as possible. For example,
you could preallocate a vector to contain all the data from the aircrafts.
In this case you would have a maximum limit hardcoded in the software, but
this is not as bad as it may seem, because the limit is *deterministic*.
One of the problems of relying on dynamic allocation is that you never know
when it is going to fail, because it depends on the amount of memory
allocated for other purposes. This technique is can't be easily applied in
Python due to the nature of the language. It is still possible to do it in
some particular cases, but not as extensively as in C/C++.
- Don't rely on a long-running process for everything. Use multiple
short-running processes for batch-style tasks, and a lightweight dispatcher
to coordinate them. The batch-style tasks must be run on separate
interpreters. While the performance penalty may be not as acceptable for
many real-time tasks, you have one specific advantage: every new instance
of the interpreter always start with a fresh memory heap. This will allow
you to avoid fragmentation-related problems, which may happen on any
platform after a long time (not to mention Win98, where it *always* happen
in few time).
The second technique must not be used alone, but it can be combined with
other optimizations with good results. The basic idea is there, it's just a
matter of using it wisely.
Carlos Ribeiro
More information about the Python-list
mailing list