A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2003-January/032178.html below:

[Python-Dev] Broken strptime in Python 2.3a1 & CVS

[Python-Dev] Broken strptime in Python 2.3a1 & CVS [Python-Dev] Broken strptime in Python 2.3a1 & CVSGuido van Rossum guido@python.org
Tue, 14 Jan 2003 19:56:06 -0500
> I expect it would be better for strptime to maintain its own internal cache
> mapping format strings to compiled regexps (as a dict, indexed by format
> strings).  Dict lookup is cheap.  In most programs, this dict will remain
> empty.  In most of the rest, it will have one entry.  *Some* joker will feed
> it an unbounded number of distinct format strings, though, so blow the cache
> away if it gets "too big":
> 
>     regexp = cache.get(fmtstring)
>     if regexp is None:
>         regexp = compile_the_regexp(fmtstring)
>         if len(cache) > 30:  # whatever
>             cache.clear()
>         cache[fmtstring] = regexp
> 
> Then you're robust against all comers (it's also thread-safe).

Yes.  I think that Brett mentioned that the compilation is
locale-aware, so it should at least fetch the relevant locale settings
and blow away the cache if the locale has changed.

--Guido van Rossum (home page: http://www.python.org/~guido/)



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4