Comparing perl and python
Nathaniel Gray
n8gray at earthlink.net
Wed Feb 23 13:03:54 EST 2000
If regexes are your concern, you may not need to worry much longer. The
regular expression engine for Python 1.6 should be significantly faster
than the current one.
Here are some benchmarks that Fredrik Lundh posted to c.l.p. last month:
0 5 50 250 1000 5000 25000
----- ----- ----- ----- ----- ----- ----- -----
search for Python|Perl in Perl ->
sre8 0.007 0.008 0.010 0.010 0.020 0.073 0.349
sre16 0.007 0.007 0.008 0.010 0.020 0.075 0.353
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 ->
sre8 0.007 0.007 0.007 0.010 0.020 0.074 0.344
sre16 0.007 0.007 0.008 0.010 0.020 0.074 0.347
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 ->
sre8 0.007 0.007 0.007 0.011 0.021 0.072 0.387
sre16 0.007 0.007 0.008 0.010 0.022 0.082 0.365
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 ->
sre8 0.008 0.007 0.008 0.011 0.021 0.079 0.379
sre16 0.008 0.008 0.008 0.011 0.022 0.075 0.402
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 ->
sre8 0.008 0.008 0.008 0.011 0.021 0.080 0.383
sre16 0.008 0.008 0.008 0.011 0.021 0.079 0.395
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 ->
sre8 0.007 0.008 0.008 0.011 0.021 0.077 0.378
sre16 0.007 0.008 0.008 0.011 0.021 0.077 0.444
re 0.108 0.107 0.134 0.240 0.637 2.765 13.395
regex 0.026 0.112 3.820 87.322 ...
search for .*P.*y.*t.*h.*o.*n.* in Python ->
sre8 0.010 0.010 0.014 0.031 0.093 0.419 2.212
sre16 0.010 0.011 0.014 0.030 0.093 0.419 2.292
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 ...
(searching for the given patterns in strings padded
with blanks on both sides. sre8 is the new python
1.6 engine on 8-bit strings, sre16 is the same engine
using unicode)
--
Nathaniel A. Gray
--
"But the sun is going down!"
"No, no, you're all confused. The horizon is moving up."
-The Firesign Theatre
--
PGP Key:
http://certserver.pgp.com:11371/pks/lookup?op=get&search=0x95345747
For PGP: http://www.pgpi.com/
More information about the Python-list
mailing list