This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients belopolsky, benjamin.peterson, donlorenzo, rsc, zanella
Date 2008-05-08.15:08:47
SpamBayes Score 0.0003800327
Marked as misclassified No
Message-id <>
In-reply-to <>
On Thu, May 8, 2008 at 10:36 AM, Russ Cox <> wrote:
>  The title of this issue (#2650) is "re.escape should not escape underscore",
>  not "re.escape is too slow and too easy to read".

Neither does the title say "re.escape should only escape
.^$*+?{}[]\|()".  I reviewed the patch rather than its conformance
with the title.  (BTW, the patch does not update documentation in

>  If you have an actual, measured performance problem with re.escape,
>  please open a new issue with numbers to back it up.
>  That's not what this one is about.

You don't need to get so defensive.  I did not raise a performance
problem, I was simply responding to Rafael's "AFAIK the lookup on
dictionaries is faster than on lists" comment.  I did not say that you
*should* rewrite your patch the way I suggested, only that you *can*
use new language features to simplify the code.

In any case, I am -0 on the patch.  The current documentation says:


   Return *string* with all non-alphanumerics backslashed; this is useful if you
   want to match an arbitrary literal string that may have regular expression
   metacharacters in it.


and the current implementation serves the intended use case well.  I
did not see a compelling use case presented for the change.  On the
downside, since there is no mechanism to assure that _special indeed
contains all re metacharacters, it may present a maintenance problem
if additional metacharacters are added in the future.
Date User Action Args
2008-05-08 15:08:52belopolskysetspambayes_score: 0.000380033 -> 0.0003800327
recipients: + belopolsky, rsc, benjamin.peterson, zanella, donlorenzo
2008-05-08 15:08:51belopolskylinkissue2650 messages
2008-05-08 15:08:48belopolskycreate