http://d.puremagic.com/issues/show_bug.cgi?id=5240
Summary: Faster std.random.uniform() for [0.0, 1.0) range Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nob...@puremagic.com ReportedBy: bearophile_h...@eml.cc --- Comment #0 from bearophile_h...@eml.cc 2010-11-19 07:16:51 PST --- std.random.uniform() is a powerful and flexible function, but some tests show that it's slow. It also calls nextafter() that is not fast. A very common use case is the generation of random doubles in the [0.0, 0.1[ range (open on the right). So I suggest to speed up this special case. This special case is present in the Python standard module "random" too, it is just named random(). A way to support it is just to add a uniform() that takes no arguments (and hopefully it doesn't need to call nextafter() inside): import std.random: uniform; void main() { double d = uniform(); // equivalent to uniform(0.0, 1.0) but faster } This function that takes no arguments may also have a name like "uniform01()" or "random()". Another special case that may be worth supporting is the generation of a random size_t. This is useful because it avoids using floating point values at all, and probably minimizes other operations too to generate it, so it may be faster still than the uniform() with no arguments. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------