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
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
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
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
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
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
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
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
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.
>
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
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
11 matches
Mail list logo