On 02/05/2016 07:50, Pavol Lisy wrote:
I just tried to extrapolate this idea a little bit.
I searched for sources with many "self" in one line and found this function in mpmath/calculus/extrapolation.py:
def factor_sidi(self, i): return (self.theta + self.n - 1) * (self.theta + self.n - 2) / self.ctx.mpf((self.theta + 2 * self.n - i - 2) * (self.theta + 2 * self.n - i - 3))
def factor_sidi(using self, i): return (.theta + .n - 1) * (.theta + .n - 2) / .ctx.mpf((.theta + 2 * .n - i - 2) * (.theta + 2 * .n - i - 3))
What dou you think? What is wrong with
def factor_sidi(self, i): theta = self.theta n = self.n return (theta + n - 1) * (theta + n - 2) / self.ctx.mpf((theta + 2 * n - i - 2) * (theta + 2 * n - i - 3)) Arguably more readable, and does 6 fewer attribute accesses.