>>> def test_func(): ... pass ... >>> import new >>> test_func2 = new.function(test_func.func_code, {}, "test_func2") >>> test_func2 <function test_func2 at 0x01B8C2F0> >>> test_func <function test_func at 0x01B8C270> >>> import timeit >>> tf = timeit.Timer("test_func()", "from __main__ import test_func") >>> tf.repeat() [0.2183461704377247, 0.18068215314489791, 0.17978585841498085] >>> tf2 = timeit.Timer("test_func2()", "from __main__ import test_func2") >>> tf2.repeat() [0.40015390239890891, 0.35893452879396648, 0.36034628133737456] >>>
Why almost twice the calling overhead for a dynamic function? -- http://mail.python.org/mailman/listinfo/python-list