Author: Benjamin Peterson <benja...@python.org> Branch: extradoc Changeset: r4135:788923bf09fc Date: 2012-03-07 16:32 -0600 http://bitbucket.org/pypy/extradoc/changeset/788923bf09fc/
Log: merge heads diff --git a/talk/pycon2012/tutorial/examples/08_re_jit.py b/talk/pycon2012/tutorial/examples/08_re_jit.py new file mode 100644 --- /dev/null +++ b/talk/pycon2012/tutorial/examples/08_re_jit.py @@ -0,0 +1,20 @@ +import re +import timeit + +welcome = "Welcome to PyCon 2011\n" * 10 + +inc_year_re = re.compile("(?P<year>\d+)") + + +def inc_year(m): + return str(int(m.group('year')) + 1) + + +simple_re = re.compile("(?P<year>\d+)") + + +print "simple_replace", timeit.timeit(lambda: simple_re.sub("2012", welcome), + number=10000) + +print "inc_replace", timeit.timeit(lambda: inc_year_re.sub(inc_year, welcome), + number=10000) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit