FAQ  •  Login

level 4 re's - to compile or not to compile?

Moderators: UncleTimmy, mjpieters

Enjoying the challenge? Need a hint?
Make a donation and help keep the site running! -thesamet


Posts: 2

Joined: Mon Nov 26, 2007 4:11 am

Post Mon Nov 26, 2007 4:18 am

level 4 re's - to compile or not to compile?

Would compiling a re.search pattern for question 4 increase the efficiency / performance? I'm guessing it would help as it is reused over and over to parse the 'next nothing'.

But how much performance does compiling re's give? When should you compile a re and when not?

Thanks in advance :)


Posts: 3

Joined: Fri Jan 04, 2008 3:49 pm

Location: Israel

Post Fri Jan 04, 2008 3:53 pm

Compiling res

Compiling res helps performance, but I'm pretty sure the biggest bottleneck you have on level 4 is the network traffic, which gives you a bigger performance penalty than uncompiled re... I usually use re.findall as it's easy and straight forward.

Like a great mind once said (Knuth, I'm pretty sure):
"Premature optimization is the root of all evil"...

Ben Blank

Posts: 3

Joined: Sat Feb 07, 2009 9:33 pm

Post Sat Feb 07, 2009 9:35 pm

Compile your regexes when they're complex and used many thousands of times in tight loops. In challenge 4, the regex is simple and used a few hundred times in a slow loop. The bottleneck is the Internet, not your regex. :-)

Return to General Discussion

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.