[Zope-Checkins] CVS: Zope3/lib/python/Zope/TAL - DummyEngine.py:1.36

Tim Peters tim@zope.com
Mon, 1 Jul 2002 14:04:22 -0400


[Barry Warsaw]
> +        cre = re.compile(r'\$(?:([_a-z]\w*)|\{([_a-z]\w*)\})',
> +                         re.IGNORECASE)
> +        return cre.sub(repl, msgid.upper())

Note that re.IGNORECASE imposes runtime costs (the engine does a function
call every time it looks at a target-string character, to normalize its
case).  Since you only pass uppercase stuff to this, it would run quicker
as:

    cre = re.compile(r'\$(?:([_A-Z]\w*)|\{([_A-Z]\w*)\})') # no IGNORECASE
    return cre.sub(repl, msgid.upper())  # unchanged