Modern C++ Lamentations
Steven Schveighoffer
schveiguy at gmail.com
Mon Dec 31 20:18:59 UTC 2018
On 12/31/18 1:43 PM, Walter Bright wrote:
> On 12/31/2018 8:05 AM, Steven Schveighoffer wrote:
> > (see my reply to that post).
>
> Your reply is:
>
> "Ooh, that's interesting. Same issue with the D version.
> I had to work a bit on it, but this does work and is 172ms vs the ~1000ms:
>
> return
> recurrence!"a[n-1]+1"(1)
> .then!((z) {
> auto ztotal = z * z;
> return iota(1, z + 1).then!((x) {
> auto xtotal = x * x;
> return iota(x, z + 1)
> .filter!(y => y * y + xtotal == total)
> .map!(y => tuple(x,y,z));
> });
> });
> "
>
> Atila, can you please update the blog post?
This isn't a fair comparison though -- I'm doing work here that in the
other languages the compiler is doing (hoisting the multiplications
outside the inner loops). It's not a straight port.
I just wanted to point out that this accounts for how the rust and C++
versions are faster than the D range versions. It would be good to look
into why the D compilers are not seeing that optimization possibility.
-Steve
More information about the Digitalmars-d
mailing list