[Pyparsing] Is it possible to optimize this grammar?
Brought to you by:
ptmcg
From: Gustavo N. <me...@gu...> - 2009-07-09 19:33:34
|
Hello, everyone. My Pyparsing grammar for boolean expressions [1] takes too much time to parse relatively complex expressions and I was wondering if it could be optimized somehow. With it, my test suite takes ~1 hour to run, while the following individual expressions take the time specified on the right (in seconds): * 'user == "gustavo"' => 0.08 * "weather:today_rains & (Pi > e | today_is_monday())" => 9.78 * "W == 0 | (X != 1 ^ (Y > 2 & Z < 3))" => 676.20 Possibly the worst of all is that these are the results on a 64-bit, 2.50GHz, 4GiB/RAM computer. So it will be many times slower on many computers. :( Is there any way I could improve the performance of this parser? Thanks in advance, [1] I've excerpted the relevant code here (it's a simplified version of the actual code): http://pyparsing.pastebin.com/f6a9c86ee -- Gustavo Narea <xri://=Gustavo>. | Tech blog: =Gustavo/(+blog)/tech ~ About me: =Gustavo/about | |