Python's Suitability?

  • Thread starter Michael R. Copeland
  • Start date
M

Michael R. Copeland

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).
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.
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...
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...).
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. 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
 
K

Kay Schluehr

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. I'm a very old procedural-based application developer (47+
years of programming experience), and developing Windows applications is
beyond me.

As I see it you might separate the console frontend from your database/
model backend and reuse your database code. The next step would be
selecting a webframework that allows you to plugin your own database
driver which has to be wrapped into a Python module. For wrapping into
a Python module there are several alternatives. SWIG and BOOST.Python
are most natural solutions for wrapping C++ code and exposing its
functionality to Python. Other options are writing a C interface to
your database and use ctypes, Pythons stdlib FFI ( see Python 2.5
docs ). Not sure if there are tools yet to derive a C interface
automatically from C++ classes. If so I would prefer the FFI approach.
For database plugins: a framework like Pylons [1] seems to be
particularly suited for this option but I would recommend requesting
answers by the Pylons community directly.

[1] http://pylonshq.com/
 
N

Nick Craig-Wood

Michael R. Copeland said:
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top