performance problem with time.strptime()
Casey Webster
Caseyweb at gmail.com
Thu Jul 2 07:45:22 EDT 2009
On Jul 2, 7:30 am, Nils Rüttershoff <n... at ccsg.de> wrote:
> Rec = re.compile(r"^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s-\s\d+\s\[(\d{2}/\w+/\d{4}:\d{2}:\d{2}:\d{2})\s\+\d{4}\].*")
> Line = '1.2.3.4 - 4459 [02/Jul/2009:01:50:26 +0200] "GET /foo HTTP/1.0" 200 - "-" "www.example.org" "-" "-" "-"'
I'm not sure how much it will help but if you are only using the regex
to get the date/time group element, it might be faster to replace the
regex with:
>>> date_string = Line.split()[3][1:-1]
More information about the Python-list
mailing list