sympy/sympy — pull request #7236 by Zamrath (2014-03-07 11:30:30+00:00)
Title: degree: Improving speed of polynomial's degree()

When calculating degree of functions like (x+1)**10000, it takes a considerable amount of time. Its because the process should first expand the function. But this can be brought into a much faster calculation in which it uses the the iterative traversal through it's arguments.

Example:

>>> eq = (4*(x+2)**1000+1)**1000
>>> eq
1000
⎛ 1000 ⎞
⎝4⋅(x + 2) + 1⎠
>>> degree(eq)
1000000

This algorithm makes the calculation to a several miliseconds whereas the older one took several minutes where I had to reboot the machine.