[Patches] [ python-Patches-670194 ] Performance enhancement for _strptime.py

SourceForge.net noreply@sourceforge.net
Fri, 17 Jan 2003 23:45:45 -0800


Patches item #670194, was opened at 2003-01-17 23:45
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=670194&group_id=5470

Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Brett Cannon (bcannon)
Assigned to: Nobody/Anonymous (nobody)
Summary: Performance enhancement for _strptime.py

Initial Comment:
Using a suggestion from Tim Peters (see http://mail.python.org/pipermail/python-dev/2003-January/032177.html for the e-mail where Tim makes his suggestion), I have added some code to _strptime.py to enhance its performance.  Specifically, I now cache a TimeRE instance and a dict containing compiled regex objects.  The TimeRE instance prevents rediscovery of locale info when the user does not change the language.  The regex object cache prevents the need to recompile regex objects when the same format string is used again and again.  Both are cleared when the language is changed.

I moved the language discovery code to a module-level function so as to make checking the current language easier.

I also removed the one use of the string module I had (has it been decided how something like string.whitespace is going to be replaced, or is that not a concern?).

I didn't bother writing any tests for this since the code changes are so simple and any breakage would have been discovered by the current tests.  But if there is a desire for tests I will do them.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=670194&group_id=5470