Next: Source to Source Transformation
Up: Source Optimization
Previous: Unreachable Code Deletion
  Contents
  Index
Multiple Values Optimization
multiple value optimization
multiple value
Within a function, Python implements uses of multiple values
particularly efficiently. Multiple values can be kept in arbitrary
registers, so using multiple values doesn't imply stack manipulation
and representation conversion. For example, this code:
(let ((a (if x (foo x) u))
(b (if x (bar x) v)))
...)
is actually more efficient written this way:
(multiple-value-bind
(a b)
(if x
(values (foo x) (bar x))
(values u v))
...)
Also, see section local-call-return for information on how local call
provides efficient support for multiple function return values.
Peter Van Eynde
2001-03-08