there already is a special inference pass for this:
https://github.com/JuliaLang/julia/blob/3b2269d835e420d16ebf6758292213bcd896df8f/base/inference.jl#L2633

but it doesn't look like it is applicable to arrays

perhaps it should be?

or perhaps, for small isint() value's, we could try using
Base.power_by_squaring?

regardless, running your benchmarks in global scope is unlikely to ever
give an accurate representation of the full range of optimizations Julia
can attempt

> You can't tell someone that "Oh sure, Julia does support that extremely
convenient syntax, but because it's 6 times slower (and it is), you need to
essentially write C".

No, you don't need to write C code. That would be the advice you get from
Matlab, Octave, Python, and most other dynamic languages. What Julia says,
is that you can write for-loops without the usual massive performance
penalty.

A wise man once told me (ok, it was Jeff, and it was about 2 years ago)
that if he wanted to make a faster MATLAB, he would have spent the last few
years writing optimized kernels for Octave. But he instead wanted to make a
new language entirely.



On Mon, Sep 8, 2014 at 4:01 PM, Stefan Karpinski <[email protected]>
wrote:

> On Mon, Sep 8, 2014 at 7:48 PM, Tony Kelman <[email protected]> wrote:
>
>>
>> Expectations based on the way Octave/Matlab work are really not
>> applicable to a system that works completely differently.
>>
>
> That said, we do want to make this faster – but we don't want to cheat to
> do it, and special casing small powers is kind of cheating. In this case it
> may be worth it, but what we'd really like is a more general kind of
> optimization here that has the same effect in this particular case.
>

Reply via email to