Python vs. Perl, which is better to learn?

James J. Besemer jb at cascade-sys.com
Thu May 9 12:39:51 EDT 2002


Patrick W wrote:

> IOW, how many is "many" and how fast is "fast enough"? These questions
> aren't really answerable without knowing more than we can know. So
> let's bury the dead and subsequently flogged horse, eh? ;-)

Well, I think it's meaningful to talk about and distinguish between "many"
and "few" without trying to quantify matters further.  I.e. my previous
question to MaxM was rhetorical.  I think I made a valid point without
quantifying "many".

> On a slightly different note, I've found that Python has occasionally
> helped me to *speed up* an application quite significantly. Reason
> being that, in C++, poor algorithms were not as easily noticeable
> whereas in Python they're intolerable.

I can't say that ever happened to me but I can see your point.

Funniest mistake I ever ran into was at one point I was supposed to come
up with a simple encryption algorithm.  Somehow I discovered "TEA" the
Tiny Encryption Algorithm, which sounded ideal:

    http://vader.brad.ac.uk/tea/tea.shtml

I figured it'd be easier to prototype in Python and in the application in
question, performance wasn't an issue.  The web page had a C version of
the algoritihm which I converted to Python in an hour or two.  I try
running it and right off I start getting integer overflow exceptions.  Of
course, the algorithm relied on a Ring of 32 bit integers and Python
complains about overflow.  I was not aware of a way to shut off the
overflow checks (still don't) and exceptions wouldn't help as they give
you control after the bad code has been taken out of circulation.  I
pondered for a while adding the necessary masking operations but decided
it was not sane.

Ended up doing it in C++ and it worked just fine.  Pretty slick little
algorithm for day to day use, although I don't know how secure it really
is.

> Actually, here's a more realistic example: The other day somebody
> asked for advice on how to store and retrieve entries in a dictionary
> using an arbitrary combination of elements in a tuple as keys. Not
> understanding his problem correctly, I suggested that he use a
> permutation algorithm as part of the solution. If he'd taken my
> advice, no language in the world could have saved his skin ;-)

It always helps to step back and look at the big picture.  I notice that's
a common failing of newbies, that they ask an overly specific question.  I
sense this is a human failing, as my kids do it about non-programming
matters.

Regards

--jb

--
James J. Besemer  503-280-0838 voice
http://cascade-sys.com  503-280-0375 fax
mailto:jb at cascade-sys.com







More information about the Python-list mailing list