{"action":"closed","issue":{"url":"https://api.github.com/repos/sympy/sympy/issues/9705","labels_url":"https://api.github.com/repos/sympy/sympy/issues/9705/labels{/name}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/9705/comments","events_url":"https://api.github.com/repos/sympy/sympy/issues/9705/events","html_url":"https://github.com/sympy/sympy/issues/9705","id":96223662,"number":9705,"title":"diff() wrt functions is much slower than diff() wrt symbols","user":{"login":"moorepants","id":276007,"avatar_url":"https://avatars.githubusercontent.com/u/276007?v=3","gravatar_id":"","url":"https://api.github.com/users/moorepants","html_url":"https://github.com/moorepants","followers_url":"https://api.github.com/users/moorepants/followers","following_url":"https://api.github.com/users/moorepants/following{/other_user}","gists_url":"https://api.github.com/users/moorepants/gists{/gist_id}","starred_url":"https://api.github.com/users/moorepants/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moorepants/subscriptions","organizations_url":"https://api.github.com/users/moorepants/orgs","repos_url":"https://api.github.com/users/moorepants/repos","events_url":"https://api.github.com/users/moorepants/events{/privacy}","received_events_url":"https://api.github.com/users/moorepants/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sympy/sympy/labels/Performance","name":"Performance","color":"fbca04"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-21T04:26:41Z","updated_at":"2015-08-12T16:36:21Z","closed_at":"2015-08-12T16:36:21Z","body":"I've seen 50x slowdowns for larger expressions, but this shows an 8x slow down:\r\n\r\n```\r\nmoorepants@moorepants-2170p:sympy(master)$ ipython\r\nPython 2.7.10 |Anaconda 2.2.0 (64-bit)| (default, May 28 2015, 17:02:03) \r\nType \"copyright\", \"credits\" or \"license\" for more information.\r\n\r\nIPython 3.2.0 -- An enhanced Interactive Python.\r\nAnaconda is brought to you by Continuum Analytics.\r\nPlease check out: http://continuum.io/thanks and https://anaconda.org\r\n?         -> Introduction and overview of IPython's features.\r\n%quickref -> Quick reference.\r\nhelp      -> Python's own help system.\r\nobject?   -> Details about 'object', use 'object??' for extra details.\r\n\r\nIn [1]: import os\r\n\r\nIn [2]: os.environ['SYMPY_CACHE_SIZE'] = '10000'\r\n\r\nIn [3]: from pydy.models import n_link_pendulum_on_cart\r\n\r\nIn [4]: sys = n_link_pendulum_on_cart(10, False, False)\r\n/home/moorepants/anaconda/lib/python2.7/site-packages/pydy/system.py:102: PyDyFutureWarning: PyDy System is experimental and may change in the future.\r\n  warnings.warn(msg, PyDyFutureWarning)\r\n\r\nIn [5]: f = sys.eom_method.forcing\r\n\r\nIn [6]: %time res = f.jacobian(sys.states)\r\nCPU times: user 10.7 s, sys: 48.2 ms, total: 10.8 s\r\nWall time: 10.7 s\r\n\r\nIn [7]: import sympy as sm\r\n\r\nIn [8]: syms = sm.symbols('x:{}'.format(len(sys.states)))\r\n\r\nIn [9]: %time vec = f.subs(dict(zip(sys.states, syms)))\r\nCPU times: user 6.8 s, sys: 88.4 ms, total: 6.88 s\r\nWall time: 6.8 s\r\n\r\nIn [10]: %time res = vec.jacobian(syms)\r\nCPU times: user 1.34 s, sys: 76.8 ms, total: 1.42 s\r\nWall time: 1.33 s\r\n\r\nIn [11]: 10.7 / 1.33\r\nOut[11]: 8.045112781954886\r\n```"}}