Newbie question - calling external Python programs

Stephen Ferg stephen_ferg at worldnet.att.net
Sat Aug 19 18:21:16 EDT 2000


My name is Steve Ferg.  I am a newbie convert to Python from Rexx.  I want
to port a big Rexx application to Python, and I need some guidance on Python
design philosophy for moderately large applications.

In Rexx, you call an external Python program like this:

     return_value = subpgm2( arg1, arg2, arg3)

When you do this, external subpgm2 is located, loaded, its byte-code is
interpreted (as in Python), and it runs.  When subpgm2 finishes, it returns
return_value and releases the memory it has used.

I've read about Python's ability to import external modules, but I'm
concerned about using the import mechanism for the application that I'm
porting.

The Rexx application is moderately large -- it is a menu-driven system where
each menu program may have options to call as many as 5 other submenu
programs, to a depth of 4 or 5 levels.   All together, there are over 100
small menu programs (about 200-1500 lines each), for a total of about
100,000 lines of Rexx code in the application.  My concern is that if I
write a top-level Python module that imports its 5 submenu programs, and all
the submenu programs import THEIR submenu programs, etc.,  that the system
will import the entire application at one shot at startup time -- that is,
import the Python-equivalent of 100,000 lines of Rexx --  and keep it in
memory.  My concern is that doing this would (1) make the program very slow
to start up, and (2) make it a memory hog when running.  I'm running under
Win98, on a 350 mHz machine, so speed and memory are not the concerns that
they would have been a few years ago, but still...

So my question is: how should I do this in Python?

Should I use import?  If so, will I find that my fears of slowness don't
materialize?  Or is there some other Python technique that should be used
for this kind of application?

Any advice would be greatly appreciated.  As a Rexx programmer, I regard
Python as a better Rexx than Rexx, and I'm really looking forward to using
Python.

-- Steve Ferg (Stephen_Ferg at att.net)





More information about the Python-list mailing list