[plt-scheme] Performance of (values x y z) vs (list x y z)?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Jun 6 04:45:00 EDT 2007

At Wed, 6 Jun 2007 18:04:00 +1000, Andrew Reilly wrote:
> Is there an expectation of a performance difference between,
> say:
> 
> (define (foo)
>   (list 1 2 3))
> 
> (define (use-foo)
>  (let ((f (foo)))
>   (let ((a (car f)) (b (cadr f)) (c (caddr f)))
>    (baz a b c))))  ; let's pretend that baz is something
>    ; complicated, in-line here, so (apply baz f) doesn't count,
>    ; although I suspect that that's related to the next part...
> 
> vs:
> 
> (define (foo)
>  (values 1 2 3))
> 
> (define (use-foo)
>  (let-values (((a b c) (foo)))
>   (baz a b c))) ; same constraint of non-triviality in a, b, c
>   ; as above
>
> [...] I'd expected the latter to be faster.

Me, too, mostly because `values' will tend not to allocate.

Matthew



Posted on the users mailing list.