Re: [julia-users] Re: Design patterns for an API

2014-05-18 Thread Mike Innes
Although it's worth pointing out the overhead is only present when using the scope workaround; if you're in an inner loop and the <1μs overhead is non-negligible (it seems unlikely that this would actually be a bottleneck, but who knows) you could just use my original macro. Overall I'm not con

Re: [julia-users] Re: Design patterns for an API

2014-05-17 Thread Mike Innes
Fair point. I timed this in a loop and it seems to be about an order of magnitude slower, which (considering that you're redefining the function every time it runs) is actually surprisingly good – it seems that doing so only takes a microsecond. On Saturday, 17 May 2014 21:20:34 UTC+1, Tim Holy

Re: [julia-users] Re: Design patterns for an API

2014-05-17 Thread Tim Holy
Right, but there are still issues with this approach. Are you planning on always executing this "function" as a macro? If so, then you'll have to pay the compilation price each time you use it. You might not care if xs is huge, but if xs has 10 items then you won't be very happy. The performanc

Re: [julia-users] Re: Design patterns for an API

2014-05-17 Thread Mike Innes
That macro being slow at the top level isn't really a strike against the macro technique, because it's easily resolved: (Although oddly enough, a let binding doesn't really help here – anyone know why?) macro sumf(f, xs) quote function inner(s = 0.0, x = $(esc(xs))) for i = 1:length

Re: [julia-users] Re: Design patterns for an API

2014-05-17 Thread Tim Holy
If you want to make that fast, you need to wrap that inside a function, using a separate name for each user-supplied f. Example: function sumf_with_sinc_plus_x(xs) @sumf(sinc_plus_x, xs) end function sumf_with_exp(xs) @sumf(exp, xs) end If you don't wrap it in a function, then it runs i

Re: [julia-users] Re: Design patterns for an API

2014-05-17 Thread Mike Innes
I may be missing the point here, but wouldn't it be easier to define sumf as a macro? macro sumf(f, xs) quote s = 0.0 x = $(esc(xs)) for i = 1:length(x) s += $(esc(f))(x[i]) end s end end @sumf(sinc_plus_x, x) This is just as fast and has the advantage that it will

Re: [julia-users] Re: Design patterns for an API

2014-05-17 Thread Tim Holy
On Friday, May 16, 2014 02:36:03 PM francois.fay...@gmail.com wrote: > - The solver need to be fast and for that, inlining is of paramount > importance. I know that there is no way to inline F for the time being. Do > we expect inlining on function argument in the near future of Julia ? I can't

Re: [julia-users] Re: Design patterns for an API

2014-05-16 Thread Isaiah Norton
Github provides a web-based issue tracker tool where many of the discussions have occurred and may be commented on: https://github.com/JuliaLang/ODE.jl/issues On Fri, May 16, 2014 at 10:26 PM, wrote: > I am new to GitHub. Is there some kind of forum, or do you mean to create > a new file with

[julia-users] Re: Design patterns for an API

2014-05-16 Thread francois . fayard
I am new to GitHub. Is there some kind of forum, or do you mean to create a new file with my thoughts on it ? On Friday, May 16, 2014 11:26:21 PM UTC+2, Alex wrote: > > so if you have a github account it might be good to post your thoughts > there as well. >

[julia-users] Re: Design patterns for an API

2014-05-16 Thread francois . fayard
Hi Alex, I do have a GitHub account, and I'll post my ideas over there. Here are my thoughts : - The solver need to be fast and for that, inlining is of paramount importance. I know that there is no way to inline F for the time being. Do we expect inlining on function argument in the near futu

[julia-users] Re: Design patterns for an API

2014-05-16 Thread Alex
Hi François, Nice to hear that you are interested in contributing to ODE.jl. Any input is greatly appreciated! I guess you have also seen some of the open issues discussing the API over at ODE.jl, so if you have a github account it might be good to post your thoughts there as well. Regarding t