[Python-Dev] Why Foo is better than Baz

Tim Peters tim_one at email.msn.com
Tue May 4 07:51:01 CEST 1999


[Tim]
> ...
> It's the *natural* semantics if Andrew's suspicion that it's
> compiling a DFA is correct ...

More from the man page:

    AREs report the longest/shortest match for the RE, rather than
    the first found in a specified search order. This may affect some
    RREs which were written in the expectation that the first match
    would be reported. (The careful crafting of RREs to optimize the
    search order for fast matching is obsolete (AREs examine all possible
    matches in parallel, and their performance is largely insensitive to
    their complexity) but cases where the search order was exploited to
    deliberately find a match which was not the longest/shortest will
    need rewriting.)

Nails it, yes?  Now, in 10 seconds, try to remember a regexp where this
really matters <wink>.

Note in passing that IDLE's colorizer regexp *needs* to search for
triple-quoted strings before single-quoted ones, else the P/P semantics
would consider """ to be an empty single-quoted string followed by a double
quote.  This isn't a case where it matters in a bad way, though!  The
"longest" rule picks the correct alternative regardless of the order in
which they're written.

at-least-in-that-specific-regex<0.1-wink>-ly y'rs  - tim






More information about the Python-Dev mailing list