threading

Chris Angelico rosuav at gmail.com
Tue Apr 8 12:46:27 EDT 2014


On Wed, Apr 9, 2014 at 2:46 AM, Paul Rubin <no.email at nospam.invalid> wrote:
> Sure, and that implies that making people wait for computer results
> costs you.  If a C++ program can run in 2 seconds while the equivalent
> Python script would take a minute, the Python version loses the user's
> attention and they have to burn time refocusing it.  Or if the C++
> version takes 12 hours and the Python version takes a month, they can
> start the C++ version at the end of their workday and have the results
> when they arrive at the office the next morning.  Then they spend the
> day examining the results and adjusting the program for the next run.
>
> Most of my stuff is in Python but there are times when your stuff just
> has to run fast.

This is true. However, this applies ONLY when you really are spending
that much computational effort and getting interactive response. Most
programs aren't like that; most interactive programs do their work in
a fraction of a second regardless of the language (the difference
between 10ms and 50ms is nothing to a human), and performance of
non-interactive servers really translates to throughput (can you
handle 100 requests a second or 200 req/s?) When you actually do have
heavy mathematical computation, often you can write your logic in
Python and have the grunt-work done at a lower level; that's what all
those numeric/scientific libraries are doing, and that's also - in
effect - what crypto libraries do for you. You don't implement
cryptography in Python; you call on a lower-level library and let it
do the work.

So the choices aren't really "write it in Python" and "write it in
C++". The choices are actually "write it in some combination of Python
and C/FORTRAN" and "write it in C++ with some libraries written in
whatever". And when you look at it like that, the difference isn't
nearly as stark as it first seemed. I'd much rather write my outer
wrapper code in something like Python than have to fiddle with all
those basics in C++; and that goes even more strongly if I have to
write any sort of UI beyond the most basic console I/O. I've written
my share of GUIs in C++, and Python beats them all hands down. Even
for basic text, it's a lot easier in Python; sure, I have printf() to
do my output, and that's fine, but for input, I'm really not happy
with either cin (C++ iostream style) or gets/scanf (C stdio style). In
Python? >>> input("Enter your name: ") and you get back a nice Unicode
string. Easy.

ChrisA



More information about the Python-list mailing list