inline-functions

Python equivalence to inline functions or macros

Python equivalence to inline functions or macros Question: I just realized that doing x.real*x.real+x.imag*x.imag is three times faster than doing abs(x)**2 where x is a numpy array of complex numbers. For code readability, I could define a function like def abs2(x): return x.real*x.real+x.imag*x.imag which is still far faster than abs(x)**2, but it is at the …

Total answers: 6