It is sometimes useful to extend Base functions behaviour by creating another function that passes through, for example:
myisapprox(a,b;kwds...) = Base.isapprox(a,b;kwds...)
# other overrides of myisapprox, which may include Base types
# so you don't want to overload Base.isapprox directly
Unfortunately, the above override is not type stable in 0.6-rc1:
Is there a way to say ācopy all definitions of Base.isapprox to myisapprox, so type stability is maintainedā? I suppose I could copy all of the keywords from Base, but this is annoying, as if I just overloaded Base.isapprox directly I wouldnāt need to do this.
Thatās standard. Since itās likely inlining the function call, your version is the exact same thing, except with an extra type-check / conversion afterwards. So your version is doing strictly more work.
Type-instability (or actually here, type-inference) issues are not necessarily a performance issue at their source. The issue is that, if you use the result of a type that is not strictly inferred, then code further down will not know the type, causing dynamic dispatch in function calls and āpropagation of the type-uncertaintiesā (i.e. causing everything else downwards to not be strictly inferred if youāre not careful!). So lack of type inference itself isnāt an issue, rather itās the fact that lack of inference in one place can make it impossible to infer the types in further code.
I think the problem may be due to keyword arguments. I donāt think thereās a better fix until keyword arguments actually dispatch correctly (thereās a PR for that), so a manual conversion should be fine. Itās ~60ns, youāll live.
Iām more concerned with allocations than time, as my particular use case builds up to MBs. Thatās very interesting that using keywords causes such a big difference:
Hmm, just realized myeps(x...) = Base.eps(x...) also destroys type stability for myeps(Float64)... I would have thought this would be type stable, as the xā¦would infer the type ofxas aTuple{Float64}`.
A few months away is a bit optimistic for a PR that just 7 days ago was getting looked again. Unless you are one of the people who thinks 1.0 is still going to be released at JuliaCon 2017
But yes, on the software side you are right about just waiting.