{"action":"created","issue":{"url":"https://api.github.com/repos/serge-sans-paille/pythran/issues/552","repository_url":"https://api.github.com/repos/serge-sans-paille/pythran","labels_url":"https://api.github.com/repos/serge-sans-paille/pythran/issues/552/labels{/name}","comments_url":"https://api.github.com/repos/serge-sans-paille/pythran/issues/552/comments","events_url":"https://api.github.com/repos/serge-sans-paille/pythran/issues/552/events","html_url":"https://github.com/serge-sans-paille/pythran/pull/552","id":142143508,"number":552,"title":"Add inlining optimisation.","user":{"login":"pbrunet","id":1872390,"avatar_url":"https://avatars.githubusercontent.com/u/1872390?v=3","gravatar_id":"","url":"https://api.github.com/users/pbrunet","html_url":"https://github.com/pbrunet","followers_url":"https://api.github.com/users/pbrunet/followers","following_url":"https://api.github.com/users/pbrunet/following{/other_user}","gists_url":"https://api.github.com/users/pbrunet/gists{/gist_id}","starred_url":"https://api.github.com/users/pbrunet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pbrunet/subscriptions","organizations_url":"https://api.github.com/users/pbrunet/orgs","repos_url":"https://api.github.com/users/pbrunet/repos","events_url":"https://api.github.com/users/pbrunet/events{/privacy}","received_events_url":"https://api.github.com/users/pbrunet/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-03-20T09:12:29Z","updated_at":"2016-03-22T19:32:54Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/serge-sans-paille/pythran/pulls/552","html_url":"https://github.com/serge-sans-paille/pythran/pull/552","diff_url":"https://github.com/serge-sans-paille/pythran/pull/552.diff","patch_url":"https://github.com/serge-sans-paille/pythran/pull/552.patch"},"body":"* Usefull to propagate more expression template.\r\n\r\nI did some test with\r\n\r\n```\r\n#pythran export bar(float[])                                                     \r\nimport numpy                                                                     \r\n                                                                                 \r\ndef foo(a):                                                                      \r\n    return numpy.cos(a)                                                          \r\n                                                                                 \r\ndef bar(c):                                                                      \r\n    return foo(c) + c * foo(c)  \r\n```\r\n\r\nand I am 10% faster. (On my slow computer...)"},"comment":{"url":"https://api.github.com/repos/serge-sans-paille/pythran/issues/comments/199978431","html_url":"https://github.com/serge-sans-paille/pythran/pull/552#issuecomment-199978431","issue_url":"https://api.github.com/repos/serge-sans-paille/pythran/issues/552","id":199978431,"user":{"login":"pbrunet","id":1872390,"avatar_url":"https://avatars.githubusercontent.com/u/1872390?v=3","gravatar_id":"","url":"https://api.github.com/users/pbrunet","html_url":"https://github.com/pbrunet","followers_url":"https://api.github.com/users/pbrunet/followers","following_url":"https://api.github.com/users/pbrunet/following{/other_user}","gists_url":"https://api.github.com/users/pbrunet/gists{/gist_id}","starred_url":"https://api.github.com/users/pbrunet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pbrunet/subscriptions","organizations_url":"https://api.github.com/users/pbrunet/orgs","repos_url":"https://api.github.com/users/pbrunet/repos","events_url":"https://api.github.com/users/pbrunet/events{/privacy}","received_events_url":"https://api.github.com/users/pbrunet/received_events","type":"User","site_admin":false},"created_at":"2016-03-22T19:32:54Z","updated_at":"2016-03-22T19:32:54Z","body":"Indead it is not an implementation error but Lazyness analysis was done to\ndetermine \"lazy\" types. In the given case, if pythran_fooa0 is a lazy type,\nas it alias on c, c is a lazy type and they will be evaluated 4 times (it\nis bad for lazy type like numpy_expr). So we assume that it is not lazy.\nBut it is based on lazy type which is stricter than FS. We should certainly\nlooks only for variable name instead of aliasing in this case.\n\n2016-03-22 20:19 GMT+01:00 serge-sans-paille <notifications@github.com>:\n\n> I reply point-by-point\n>\n>\n> > I am not sure I need more tests as recursion is already tested with many\n> others cases and the basic transformation is tested with doctest.\n>\n> Right now your tests are very conservative. We may want to extend them\n> later on (eg to support more complex inlining situations)\n>\n> > I do the suggested modiciation but sadly ForwardSubstition doesn't\n> really help here :s\n> >\n> > ```\n> > #pythran export bar(float[])\n> > import numpy\n> >\n> > def foo(a):\n> > return numpy.cos(a)\n> >\n> > def bar(c):\n> > return foo(c) + c * foo(c)\n> > ```\n> >\n> > In this case, bar will become :\n> > ```\n> > def bar(c):\n> > _pythran_fooa0 = c\n> > _pythran_fooa1 = c\n> > return numpy.cos(_pythran_fooa0) + c * numpy.cos(_pythran_fooa1)\n> > ```\n>\n>\n> The primary goal was to better handle\n>\n> ```\n> def foo(a):\n> return coas(a) + sin(a)\n> ```\n>\n> when the call site is\n>\n> ```\n> foo(b +c)\n> ```\n>\n> And your proposal should already improve the situation.\n>\n> > ForwardSubstition can't substitute here as pythran_fooa0 alias on `c` so\n> it is use 4 times (no FS if it is use more than once)\n> > May be we should improve FS to foward with more than one \"use\" in the\n> case of \"simple variable assignment\"?\n>\n> Isn't this an error in our FS implementation? I see only one use of\n> _pythran_fooa0...\n>\n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly or view it on GitHub\n> <https://github.com/serge-sans-paille/pythran/pull/552#issuecomment-199972249>\n>\n"}}