Hi, I’m quite new to Julia and I’m looking for suggestions to improve the performance of my code to hopefully beat the Python version. From these 2 functions do you see any margin of improvement?

For example I’am trying to avoid allocations but I don’t think I can apply the method provided in this example Performance Tips · The Julia Language

I appreciate any help.

```
function _logS(MF::AbsPL, m::Vector{Float64})
δm, ml = MF.δm, MF.ml
s = zeros(size(m)) # already ok for mask_upp
mask_low = @. m <= ml
mask_mid = @. (m > ml) & (m < (ml + δm))
s[mask_mid] = @. -log1pexp( δm/(m[mask_mid]-ml) + δm/(m[mask_mid]-(ml+δm)) )
s[mask_low] .= -Inf
s
end
function _logC(MF::AbsBPL, m::Vector{Float64}, N=200)
δm, ml = MF.δm, MF.ml
xx = sort(vcat(LinRange(ml, ml+δm+0.1*δm, N),
LinRange(ml+δm+0.1*δm+0.1, maximum(m), N)))
cdf = cumul_integrate(xx, exp.(_logpdfm2(MF, xx)), TrapezoidalFast())
intcdf = LinearInterpolation(xx, cdf, extrapolation_bc = NaN)(m)
-log.(intcdf)
end
function _logpdfm1(MF::AbsBrokenPLMF, m::Vector{Float64})
α1, α2, ml, mu, m_break = MF.α1, MF.α2, MF.ml, MF.mu, MF.m_break
res = fill(NaN, size(m))
mask_compute = @. (ml < m) & (m < mu)
mm = m[mask_compute]
res[mask_compute] = ifelse.(mm .< m_break,
(-α1 .* log.(mm)) .+ _logS(MF, mm),
(-α2 .* log.(mm)) .+ _logS(MF, mm) .+ (α2-α1)*log(m_break))
res
end
```