Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Notice that g is making a python function call, while f is accomplishing its task without any python function calls:

sage: z = var('z')
sage: f = fast_callable(exp(z).abs(),domain=CDF,vars='z')
sage: g = fast_callable(exp(z.real()), domain=CDF, vars='z')
sage: f.python_calls()
sage: g.python_calls()
sage: f.op_list()
[('load_arg', 0), 'exp', 'abs', 'return']
sage: g.op_list()
[('load_arg', 0), ('py_call', real_part, 1), 'exp', 'return']

However, I get timings that are pretty equivalent:

sage: a=4+2*I
sage: timeit('f(a)')
625 loops, best of 3: 385 µs per loop
sage: timeit('g(a)')
625 loops, best of 3: 386 µs per loop