Python vs. Perl, which is better to learn?

Andrew Dalke dalke at dalkescientific.com
Wed May 1 00:48:29 EDT 2002


Geoff Gerrietts :
>Of particular interest to me (and maybe Perl does this now, but it
>didn't when I was deep into Perl Zen) is the way you can name
>subpatterns in Python -- that allows you to use your parens for
>grouping, and not hafta pick through the countless groups for the
>actual pieces you want to extract.

It doesn't handle that.  I mentioned that to Damian Conway as one
of the things to consider supporting in Perl6, since I agree --
I use them all the time for my work.

>I also appreciate the way Python actively encourages a person to
>compile their regular expressions -- Perl doesn't, which leads to
>continually re-constructing the state machine (unless they've
>optimized that since I was deep into Perl Zen).

That was supported even when I started with Perl 4.036.  It
just doesn't look like it works that way.

http://www.perldoc.com/perl5.6.1/pod/perlretut.html
] Even with all this work, regexp matching happens remarkably fast.
] To speed things up, during compilation stage, perl compiles the
] regexp into a compact sequence of opcodes that can often fit
] inside a processor cache.

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list