Advice: socket handling and threads

Dan Williams dan at ithium.net
Wed Feb 4 10:32:56 EST 2004


Hi people

Part of the reason I have started using Python (experience: 3 days) is that
I recognise the potential benefits in using it compared to writing C/C++
code. In particular, there are a couple of modules in an application that I
am writing that I have calculated will be up to ten times quicker to develop
(although it is hard to say at this stage), which is obviously quite
attractive.

The "problem" I have is relating to the existing C++ code I have. I've
started porting it to Python, so that the whole project will be in the same
language. The main aspects of my app that I am wondering about are socket
handling and multi-threading.

As far as I understand, Python can do everything that C/C++ can do with
sockets, plus there are the thread and threading modules which I believe are
equivalent to the pthreads module I have been using so far. My question is
this:

Is it sensible to port these sections of code to Python? Do I stand to gain
or lose by doing this... I doubt the performance difference will be
noticeable, and the only areas of the project that I would maybe consider
extending in C++ are to do with parsing (and to be honest I think it'll be
fine left in Python).

Finally there is the cherry on the cake in the form of cross-platform
compatibility. My C++ code only works on *nix (or cygwin) but as far as I
understand it, my threads and sockets should work fine on Windows and Mac
too, if done in Python...? (This is a CLI app not GUI by the way.)

Thoughts and general musings will be greatly appreciated (as will any
warnings of pitfalls I may encounter!)

Dan







More information about the Python-list mailing list