Python's Suitability?

Nick Craig-Wood nick at craig-wood.com
Tue Aug 28 13:30:07 CEST 2007


Michael R. Copeland <mrc2323 at cox.net> wrote:
>     I have some questions about the suitability of Python for some 
>  applications I've developed in C/C++.  These are 32 bit Console 
>  applications, but they make extensive use of STL structures and 
>  functions (Lists, Maps, Vectors, arrays) - primarily because the data 
>  volume is high (2,500,000+ records).

This is all bread and butter stuff to python and 10 times easier to do
in python than C++!

>     The main thing I'd like to do is port one part of the system that has 
>  a series of user menus and works with several text data files (one 
>  _very_ large).  I'm not using any database system, just my home-grown 
>  indexed sequential file database.  There's nothing but volume that 
>  precludes this application from running from almost any text file-
>  processing language system (e.g. Perl, BASIC, etc.).
>     From what little I've seen of Python, it appears I could port this 
>  application to Python code, but I'd do so only if I could:
>    1. Integrate it into a Web application in such a way that the user 
>  could select it as an option from a main page and have it execute as a 
>  WEB GUI application.  Currently, the application's interface is only a 
>  crude DOS window.

A web application is possible.  You can start your application which
would run its own embedded web server which the user could then
control.  Python has a web server in the standard library.  I've done
exactly this using cherrypy as a simple web application framework.

The asynchronous nature of web applications are often a pain.  You
could write a windows GUI using TKinter (which comes with python) or
WxPython (which doesn't).  Those toolkits make it very easy to make
GUI applications.

>    2. Assure that the performance isn't totally crippled by using Python, 
>  an interpretted language.  While I don't expect native C/C++ 
>  performance, I don't want to be embarrassed...

Depends exactly what you are doing.  If you are IO limited then Python
is just as fast as C++.

If you are doing lots of calculation on the data then python can be
slow.  You can use the numpy library which is a library of scientific
maths routines all coded in C for speed which is very quick.

  http://numpy.scipy.org
  http://sourceforge.net/projects/numpy

>    3. Make sure that the volume of stored data (2.5+ million records) can 
>  be accommodated in Python structures (I don't know enough about Python 
>  to answer this question...).

I wouldn't have thought that would be a problem.

>     Note that I'm not considering using the existing C/C++ code in my Web 
>  application, because I don't know how to write a C/C++ Windows 
>  application - and I'm sure the learning curve here is greater than 
>  Python's.

You could always use ctypes from python to interface with your C
code.  If you can export your code in a DLL then ctypes can use it.
(Not sure about C++ though)

> I'm a very old procedural-based application developer (47+ 
>  years of programming experience), and developing Windows applications is 
>  beyond me.
>     So, I only (?) want to take an existing application that uses a large 
>  text file (and several smaller text indexing files) and put it into a 
>  Web system I already have.  I feel Python (or Perl) is(are) my best 
>  option(s), and here I'm only looking for some initial guidance from the 
>  Python users.  TIA

Go for it!  Python is such an easy language to write stuff in
(escpecially compared to C++) that you'll have the prototype done very
quickly and you can evaluate the rest of your concerns with working
code!

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list