[racket-dev] for loop singleton optimization

From: J. Ian Johnson (ianj at ccs.neu.edu)
Date: Wed Nov 28 12:50:49 EST 2012

It would be great to optimize singletons out of comprehensions, since I (and probably others) have macros that expand into singleton constructors that are much better suited to just be a rebinding.

> (time (for ([n (in-range 1 1000000)]) (for ([k (in-set (set n))]) (random k))))
cpu time: 340 real time: 338 gc time: 16
> (time (for ([n (in-range 1 1000000)]) (for ([k (in-value n)]) (random k))))
cpu time: 120 real time: 118 gc time: 0

Is this easily added to for.rkt?

-Ian

Posted on the dev mailing list.