re.search much slower then grep on some regular expressions

Henning Thornblad Henning.Thornblad at gmail.com
Mon Jul 7 12:51:40 EDT 2008


When trying to find an alternative way of solving my problem i found
that running this script:

#!/usr/bin/env python

import re

row=""
for a in range(156000):
    row+="a"
print "How many, dude?"
print re.search('/[^ "=]*',row)  (the / has moved)

wouldn't take even a second (The re.search part of course)

This is for me very strange since this,
in theory, is the same problem as before.

/Henning Thornblad



More information about the Python-list mailing list