[Brett Cannon] > ... > And to comment on the speed drawback: there is already a partial solution > to this. ``_strptime`` has the ability to return the regex it creates to > parse the data string and then subsequently have the user pass that in > instead of a format string:: You're carrying restructured text too far <wink>:: 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).
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