Python versus Perl

Michael Sparks michaels at rd.bbc.co.uk
Wed Sep 7 05:47:22 EDT 2005


Dieter Vanderelst wrote:

> Dear all,
> 
> I'm currently comparing Python versus Perl to use in a project that
> involved a lot of text processing. I'm trying to determine what the
> most efficient language would be for our purposes. I have to admit
> that, although I'm very familiar with Python, I'm complete Perl noob
> (and I hope to stay one) which is reflected in my questions.
> 
> I know that the web offers a lot of resources on Python/Perl
> differences. But I couldn't find a satisfying answer to my questions:
> 
> 1 - How does the speed of execution of Perl compares to that of
> Python?

Much of a muchness in my experience.(Qualitative, not quantative)

> 2 - Regular Expressions are a valuable tool in text processing. I have
> noticed that Regular Expressions are executed very fast in Python.
> Does anybody know whether Python executes RE faster than Perl does?
> 3 - In my opinion Python is very well suited for text processing. Does
> Perl have any advantages over Python in the field of textprocessing
> (like a larger standard library maybe).

These two are related. If you're writing code and you expect to be
using *a lot* of regular expression [*] type code then you may find perl
more convenient.

   [*] That /might/ suggest you're taking the wrong approach mind you...

Python, for me, tends to be more readable, both immediately after
writing and if I go back to a year later - for maintenance, extension
etc.

Personally I like both languages for day in day out use, but these days
tend to choose python if I think I'm likely to want to modify or extend
the code. With the exception being where I'm doing heavy text
processing work that I think will be more maintainable in perl, or I'm
really sure I won't have to maintain it. (eg quick and dirty scripts)

One side effect of perl usage though is that due to them being easy to
use and convenient, they can get over used. (Rather than thinking
"what's the best way of solving this problem", people can end up
thinking "What regular expression can solve this problem" - which isn't
ideal)

Your comment """I'm complete Perl noob (and I hope to stay one) """
would suggest to me that if you really feel that way, stay that way :-)
(Though personally I do like learning new programming languages, since
you get more idioms and tools under your belt that way.)

> I hope somebody can answer my questions. Of course, every remark and
> tip on Python/Perl in texprocessing is most welcome.

In case you're not aware there's the book "Text Processing in Python" by
David Mertz, which is available online in a "free as in beer" form
which might be of use if you decide python instead of perl.


Michael.
-- 
Michael.Sparks at rd.bbc.co.uk, http://kamaelia.sourceforge.net/
British Broadcasting Corporation, Research and Development
Kingswood Warren, Surrey KT20 6NP

This message (and any attachments) may contain personal views
which are not the views of the BBC unless specifically stated.




More information about the Python-list mailing list