re.match() performance
Pierre-Alain Dorange
pdorange at pas-de-pub-merci.mac.com
Thu Dec 18 09:21:16 EST 2008
Emanuele D'Arrigo <manu3d at gmail.com> wrote:
> I've written the code below to test the differences in performance
> between compiled and non-compiled regular expression matching but I
> don't quite understand the results. It appears that the compiled the
> pattern only takes 2% less time to process the match. Is there some
> caching going on in the uncompiled section that prevents me from
> noticing its otherwise lower speed?
Running your sample i got also a 2% the first time, but next time i got
a different speed : 4 time faster.
Running 1st time
Pattern Matching Time: 0.122432
(Compiled) Pattern Matching Time: 0.12012
Ratio Compiled/NotCompiled: 0.981116048092
2nd time and more
Pattern Matching Time: 0.00257
(Compiled) Pattern Matching Time: 0.000619
Ratio Compiled/NotCompiled: 0.240856031128
Config python 2.5.1 / MacOS X 10.5
--
Pierre-Alain Dorange <http://microwar.sourceforge.net/>
Ce message est sous licence Creative Commons "by-nc-sa-2.0"
<http://creativecommons.org/licenses/by-nc-sa/2.0/fr/>
More information about the Python-list
mailing list