From: Stefan Behnel
Date: Fri, Jul 26, 2013 at 1:35 AM
Subject: small performance patch for Tempita

we're using Tempita for some code generation bits in Cython (simply because
it's small enough to embed it), and I found that it spends quite some
processing time figuring out the line/column position in the template.
Initialisation time is important because templates are often just executed
once or a couple of times in Cython. Here's a little patch that speeds that
part up. The main problem is string.splitlines(), which adds a substantial
overhead for just counting lines.

The patch doesn't care about the line ending format of the file, not sure
if that's a problem. You might want to use regexes if it is. Also, I didn't
really find any tests for this code, so I've probably broken it with an
off-by-one or something. It seems to give the same error positions as
before, though.

Stefan