[racket] generator performance

From: Greg Hendershott (greghendershott at gmail.com)
Date: Tue Sep 18 07:07:51 EDT 2012

This stuff is still over my head; I'm at that "know just enough to be
dangerous" stage. With that caveat:

Jay's blog post
http://jeapostrophe.github.com/blog/2012/07/25/cont-marks2/ mentions
that parameters can be >10X slower than dynamic-wind.

In generator.rkt I notice an early version that didn't support
multiple values. The new version does, keeping a "yielder" proc in a

Could a single-valued generator yield be faster enough?  Or am I
misapplying my misunderstanding? :)

On Sun, Sep 16, 2012 at 11:15 AM, Eli Barzilay <eli at barzilay.org> wrote:
> 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
> possible.
> --
>           ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
>                     http://barzilay.org/                   Maze is Life!
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.