faster way to handle time string with python
<p>I have many log files with the format like:</p>

<pre><code>2012-09-12 23:12:00 other logs here
</code></pre>

<p>and i need to extract the time string and compare the time delta between two log records.
I did that with this:</p>

<pre><code>for line in log:
    l = line.strip().split()
    timelist = [int(n) for n in re.split("[- :]", l[0]+' ' + l[1])]
    #now the timelist looks like [2012,9,12,23,12,0]
</code></pre>

<p>Then when i got two records        </p>

<pre><code>d1 = datetime.datetime(timelist1[0], timelist1[1], timelist1[2], timelist1[3], timelist1[4], timelist1[5])
d2 = datetime.datetime(timelist2[0], timelist2[1], timelist2[2], timelist2[3], timelist2[4], timelist2[5])
delta = (d2-d1).seconds
</code></pre>

<p>The problem is it runs slowly,is there anyway to improve the performance?Thanks in advance.</p>
