[racket] generator performance

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Sep 16 11:15:01 EDT 2012

Two hours ago, Patrick Useldinger wrote:
> Hello
> I have a Python program doing some intensive computing and would
> like to port it to Racket for performance reasons.
> I use a generator in Python which has a very low overhead. While
> writing some test programs, I seem to have an substantial overhead
> on using generators in Racket:
> [...]

IIRC, Python optimizes generators in some ways when possible so when
they're used with loops there's no big overhead.  The racket
generators are implemented with continuations and the cost that comes
with that is unfortunately pretty high.  If you need performance, your
best bet is probably to translate things to `for...' loops if

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the users mailing list.