471,601 Members | 1,226 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,601 software developers and data experts.

Python's Suitability?

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
Aug 28 '07 #1
2 1894
On 28 Aug., 02:28, mrc2...@cox.net (Michael R. Copeland) wrote:
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/
Aug 28 '07 #2
Michael R. Copeland <mr*****@cox.netwrote:
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 <ni**@craig-wood.com-- http://www.craig-wood.com/nick
Aug 28 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

226 posts views Thread by Stephen C. Waterbury | last post: by
36 posts views Thread by Andrea Griffini | last post: by
4 posts views Thread by Xah Lee | last post: by
68 posts views Thread by Lad | last post: by
20 posts views Thread by xeys_00 | last post: by
122 posts views Thread by Edward Diener No Spam | last post: by
2 posts views Thread by Paul Boddie | last post: by
17 posts views Thread by chewie54 | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.