Recoded dmp_zero_p to be non-recursive
Recoded dmp_zero_p to be non-recursive

A simple cProfile.run('integrate(x**2*exp(x)*sin(x), x)', sort=1)
reveals that most of the time is spent in dmp_zero_p for this integral.
However, it was coded recursively, when it is trivial to code it
non-recursively. This makes it faster:

In [11]: def rec_dmp_zero_p(f, u): # this is the old version
    if not u:
        return not f
    else:
        if len(f) == 1:
            return rec_dmp_zero_p(f[0], u - 1)
        else:
   ....:             return False
   ....:
   ....:

In [18]: def non_rec_dmp_zero_p(f, u): # this is the new version
   ....:     while u:
   ....:         if len(f) != 1:
   ....:             return False
   ....:         f = f[0]
   ....:         u -= 1
   ....:     return not f
   ....:

In [19]: f = [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[-3
   ....: ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

In [24]: u = 46

In [25]: rec_dmp_zero_p(f, u)
Out[25]: False

In [26]: non_rec_dmp_zero_p(f, u)
Out[26]: False

In [27]: g = [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
   ....: ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

In [28]: rec_dmp_zero_p(g, u)
Out[28]: True

In [29]: non_rec_dmp_zero_p(g, u)
Out[29]: True

In [30]: %timeit rec_dmp_zero_p(f, u)
10000 loops, best of 3: 23.8 us per loop

In [31]: %timeit non_rec_dmp_zero_p(f, u)
100000 loops, best of 3: 14.3 us per loop

In [32]: %timeit rec_dmp_zero_p(g, u)
10000 loops, best of 3: 22.8 us per loop

In [33]: %timeit non_rec_dmp_zero_p(g, u)
100000 loops, best of 3: 15.1 us per loop

And in the end, we find that the integral runs a little faster:

Before:

In [1]: %timeit integrate(x**2*exp(x)*sin(x), x)
1 loops, best of 3: 7.49 s per loop

After:

In [1]: %timeit integrate(x**2*exp(x)*sin(x), x)
1 loops, best of 3: 6.27 s per loop

grevutiu-gabriel/sympy,Shaswat27/sympy,jaimahajan1997/sympy,sunny94/temp,debugger22/sympy,jerli/sympy,Shaswat27/sympy,ChristinaZografou/sympy,sahilshekhawat/sympy,hrashk/sympy,MridulS/sympy,farhaanbukhsh/sympy,shikil/sympy,mcdaniel67/sympy,bukzor/sympy,MechCoder/sympy,lindsayad/sympy,sahilshekhawat/sympy,yukoba/sympy,Curious72/sympy,maniteja123/sympy,ahhda/sympy,maniteja123/sympy,AkademieOlympia/sympy,mafiya69/sympy,Mitchkoens/sympy,wanglongqi/sympy,sahmed95/sympy,sunny94/temp,skidzo/sympy,lindsayad/sympy,Shaswat27/sympy,kaichogami/sympy,cswiercz/sympy,aktech/sympy,bukzor/sympy,cccfran/sympy,wyom/sympy,chaffra/sympy,asm666/sympy,kevalds51/sympy,emon10005/sympy,aktech/sympy,vipulroxx/sympy,lindsayad/sympy,AunShiLord/sympy,Arafatk/sympy,rahuldan/sympy,liangjiaxing/sympy,saurabhjn76/sympy,bukzor/sympy,kmacinnis/sympy,iamutkarshtiwari/sympy,atreyv/sympy,Curious72/sympy,yashsharan/sympy,atsao72/sympy,garvitr/sympy,kumarkrishna/sympy,kaushik94/sympy,ChristinaZografou/sympy,ga7g08/sympy,ga7g08/sympy,Designist/sympy,saurabhjn76/sympy,madan96/sympy,yukoba/sympy,hargup/sympy,garvitr/sympy,pbrady/sympy,souravsingh/sympy,Davidjohnwilson/sympy,hargup/sympy,wanglongqi/sympy,atsao72/sympy,dqnykamp/sympy,Sumith1896/sympy,beni55/sympy,kumarkrishna/sympy,jaimahajan1997/sympy,jbbskinny/sympy,beni55/sympy,emon10005/sympy,farhaanbukhsh/sympy,jamesblunt/sympy,vipulroxx/sympy,yashsharan/sympy,Gadal/sympy,vipulroxx/sympy,AkademieOlympia/sympy,diofant/diofant,meghana1995/sympy,drufat/sympy,atsao72/sympy,abloomston/sympy,jerli/sympy,amitjamadagni/sympy,postvakje/sympy,shipci/sympy,shipci/sympy,lidavidm/sympy,cswiercz/sympy,jbbskinny/sympy,oliverlee/sympy,jamesblunt/sympy,MridulS/sympy,abloomston/sympy,toolforger/sympy,liangjiaxing/sympy,kumarkrishna/sympy,mcdaniel67/sympy,kaushik94/sympy,Vishluck/sympy,Davidjohnwilson/sympy,saurabhjn76/sympy,Titan-C/sympy,Arafatk/sympy,moble/sympy,grevutiu-gabriel/sympy,kmacinnis/sympy,pandeyadarsh/sympy,madan96/sympy,sahmed95/sympy,sahmed95/sympy,Titan-C/sympy,pbrady/sympy,garvitr/sympy,cccfran/sympy,debugger22/sympy,iamutkarshtiwari/sympy,wanglongqi/sympy,pandeyadarsh/sympy,maniteja123/sympy,debugger22/sympy,meghana1995/sympy,postvakje/sympy,toolforger/sympy,wyom/sympy,abhiii5459/sympy,Vishluck/sympy,sahilshekhawat/sympy,souravsingh/sympy,oliverlee/sympy,AunShiLord/sympy,drufat/sympy,emon10005/sympy,beni55/sympy,cccfran/sympy,VaibhavAgarwalVA/sympy,ga7g08/sympy,skirpichev/omg,shipci/sympy,jbbskinny/sympy,dqnykamp/sympy,pandeyadarsh/sympy,Sumith1896/sympy,skidzo/sympy,abloomston/sympy,pbrady/sympy,kaushik94/sympy,atreyv/sympy,wyom/sympy,MridulS/sympy,Davidjohnwilson/sympy,Arafatk/sympy,grevutiu-gabriel/sympy,meghana1995/sympy,moble/sympy,VaibhavAgarwalVA/sympy,Gadal/sympy,skidzo/sympy,MechCoder/sympy,rahuldan/sympy,ChristinaZografou/sympy,mafiya69/sympy,jaimahajan1997/sympy,kaichogami/sympy,ahhda/sympy,sampadsaha5/sympy,jerli/sympy,chaffra/sympy,asm666/sympy,AunShiLord/sympy,kevalds51/sympy,cswiercz/sympy,drufat/sympy,aktech/sympy,atreyv/sympy,Titan-C/sympy,amitjamadagni/sympy,oliverlee/sympy,shikil/sympy,Mitchkoens/sympy,abhiii5459/sympy,yukoba/sympy,chaffra/sympy,jamesblunt/sympy,rahuldan/sympy,mcdaniel67/sympy,sampadsaha5/sympy,sampadsaha5/sympy,Mitchkoens/sympy,ahhda/sympy,Curious72/sympy,shikil/sympy,MechCoder/sympy,liangjiaxing/sympy,hrashk/sympy,moble/sympy,dqnykamp/sympy,souravsingh/sympy,mafiya69/sympy,AkademieOlympia/sympy,kevalds51/sympy,Designist/sympy,sunny94/temp,iamutkarshtiwari/sympy,lidavidm/sympy,lidavidm/sympy,Sumith1896/sympy,asm666/sympy,farhaanbukhsh/sympy,VaibhavAgarwalVA/sympy,hrashk/sympy,kaichogami/sympy,postvakje/sympy,toolforger/sympy,Designist/sympy,madan96/sympy,yashsharan/sympy,hargup/sympy,kmacinnis/sympy,Vishluck/sympy,Gadal/sympy,abhiii5459/sympy