www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15722] New: std.algorithm sum should favour speed

https://issues.dlang.org/show_bug.cgi?id=15722

          Issue ID: 15722
           Summary: std.algorithm sum should favour speed
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: adamsibson hotmail.com

From the Learn forum thread
https://forum.dlang.org/post/vkiwojmfjrwhigbkenaa forum.dlang.org it became apparent that sum is four times slower (on DMD and LDC) than the naive loop sum method and similarly slower than reduce!((a, b) => a + b). Would it not be better to have a fast, basic implementation in algorithm and a slower, more accurate version in a sub-library? The performance gap is too large to justify the current version being the standard. I would suggest that most users just want a trivial sum function and the more technical users are capable of finding and using the more accurate version, especially if we properly document the library. The accuracy of the basic version is also not terrible, it's usually going to be good enough. This is not playing fast and loose with accuracy just for the sake of a few percent speed. This kind of poor performance iceberg reflects poorly on D for new users. It's not the right out of box experience. --
Feb 25 2016