[racket] generator performance

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Sep 18 08:26:59 EDT 2012

An hour ago, Greg Hendershott wrote:
> In generator.rkt I notice an early version that didn't support
> multiple values. The new version does, keeping a "yielder" proc in a
> parameter.
> 
> Could a single-valued generator yield be faster enough?  Or am I
> misapplying my misunderstanding? :)

That's not the main difference between the two.  It's an earlier
experiment where the `yield' is bound staticaly as a syntax parameter
instead of a dynamic one.  The resulting generator facility is closer
to python, where `yield' must appear in the body of the generator.
So, for example, you can't write some helper for generators like

  (define (yield-3 n)
    (yield (sub1 n))
    (yield n)
    (yield (add1 n)))

I think that it's not as bad as python, since you can still write such
a helper and pass `yield' as an argument.  (At least as much as I
tried, I couldn't get python to use it as a value.)

Our assumption at the time was that the cost of the parameter is much
smaller than the continuation, but we never really tried to measure
it.

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

Posted on the users mailing list.