Running under Python 2.7.6 on Ubuntu 14.04: Mon Aug 29 16:17:38 2016 /tmp/profile 90388000 function calls (88164345 primitive calls) in 2980.718 seconds Ordered by: internal time List reduced from 1293 to 10 due to restriction <10> ncalls tottime percall cumtime percall filename:lineno(function) 360 2847.099 7.909 2847.099 7.909 {posix.waitpid} 7556927 14.850 0.000 22.984 0.000 /usr/lib/python2.7/sre_parse.py:182(__next) 329052/19969 14.153 0.000 66.094 0.003 /usr/lib/python2.7/sre_parse.py:379(_parse) 21228753/21056054 11.622 0.000 11.818 0.000 {len} 14781340 8.213 0.000 8.213 0.000 {method 'append' of 'list' objects} 501625/19869 8.185 0.000 34.260 0.002 /usr/lib/python2.7/sre_compile.py:32(_compile) 6577687 7.884 0.000 27.879 0.000 /usr/lib/python2.7/sre_parse.py:201(get) 486296 7.675 0.000 12.117 0.000 /usr/lib/python2.7/sre_compile.py:207(_optimize_charset) 3228296 4.020 0.000 6.069 0.000 /usr/lib/python2.7/sre_parse.py:130(__getitem__) 6187868 3.826 0.000 3.826 0.000 {isinstance} -------------------------------------------------------------------------------------------------------------- Same regular-expression-intensive Python code, running under Python 2.7.12 on Ubuntu 16.04: Mon Aug 29 16:39:39 2016 /tmp/profile 91532568 function calls (89306823 primitive calls) in 4519.872 seconds Ordered by: internal time List reduced from 1680 to 10 due to restriction <10> ncalls tottime percall cumtime percall filename:lineno(function) 359 4474.890 12.465 4474.890 12.465 {posix.waitpid} 329393/20019 6.653 0.000 19.739 0.001 /usr/lib/python2.7/sre_parse.py:395(_parse) 7568367 4.649 0.000 5.419 0.000 /usr/lib/python2.7/sre_parse.py:193(__next) 502230/19911 3.076 0.000 8.468 0.000 /usr/lib/python2.7/sre_compile.py:64(_compile) 14 2.469 0.176 32.667 2.333 {cPickle.load} 486486 1.765 0.000 2.893 0.000 /usr/lib/python2.7/sre_compile.py:256(_optimize_charset) 6588346 1.739 0.000 6.432 0.000 /usr/lib/python2.7/sre_parse.py:212(get) 21929242/21756251 1.243 0.000 1.279 0.000 {len} 629992/159215 1.177 0.000 1.435 0.000 /usr/lib/python2.7/sre_parse.py:151(getwidth) 78541 1.113 0.000 1.113 0.000 {posix.remove}