Suitability of Python for a Big Application?
Fredrik Lundh
fredrik at pythonware.com
Mon Dec 13 04:01:58 EST 1999
Hans Nowak <hnowak at cuci.nl> wrote:
> The short answer: no. The long answer: It depends. I don't know
> enough of regexen to tell you more, though. I do know that the re
> library is kinda slow compared to Perl and the (older and deprecated)
> regex library.
an even longer answer: 're' has more initial call
overhead than 'regex', but runs much faster.
if you apply many small regular expressions to the
same string, regex is faster. if you use more com-
plicated regular expressions, or work with large
strings, 're' can be much faster.
$ python re_bench.py
0 5 50 250 1000 5000 25000
----- ----- ----- ----- ----- ----- ----- -----
search for Python|Perl in Perl ->
re 0.097 0.097 0.101 0.103 0.118 0.175 0.480
regex 0.007 0.007 0.009 0.020 0.059 0.271 1.320
search for (Python|Perl) in Perl ->
re 0.110 0.104 0.111 0.115 0.125 0.184 0.559
regex 0.006 0.006 0.009 0.019 0.057 0.285 1.432
search for Python in Python ->
re 0.107 0.097 0.105 0.102 0.118 0.175 0.511
regex 0.009 0.008 0.010 0.018 0.036 0.139 0.708
search for .*Python in Python ->
re 0.102 0.108 0.119 0.183 0.400 1.545 7.284
regex 0.013 0.019 0.072 0.318 1.231 8.035 45.366
search for .*Python.* in Python ->
re 0.103 0.108 0.119 0.184 0.418 1.685 8.378
regex 0.013 0.020 0.073 0.326 1.264 9.961 46.511
search for .*(Python) in Python ->
re 0.108 0.107 0.134 0.240 0.637 2.765 13.395
regex 0.026 0.112 3.820 87.322 (skipped)
search for .*P.*y.*t.*h.*o.*n.* in Python ->
re 0.112 0.121 0.195 0.521 1.747 8.298 40.877
regex 0.026 0.048 0.248 1.148 4.550 24.720 (skipped)
(the number above each column is the padding
size; a junk string of that length is added to each
side of the target string)
and yes, this will most likely be fixed in 1.6...
</F>
More information about the Python-list
mailing list