From octave-maintainers-request at bevo dot che dot wisc dot edu Mon Jan 13 21:22:00 2003 Subject: Re: overloaded functions From: Paul Kienzle To: Andy Adler Cc: octave-maintainers at bevo dot che dot wisc dot edu Date: Mon, 13 Jan 2003 22:20:25 -0500 Andy Adler wrote: >[dispatch is] a really useful function, Paul. > >Does it add any significant overhead? > A lookup in a very small hash table, an extra feval call, so yes it is a little bit expensive. octave:10> tic; for i=1:1000, sin(1); end; toc ans = 0.047647 octave:11> tic; for i=1:1000, cos(1); end; toc ans = 0.037207 If you wanted to, you could keep the actual function values in the structure, and so avoid the extra feval. Since the number of types we are likely to dispatch against is small, an array is perhaps a better representation then a map. You could be using type-ids rather than strings to compare types. This might be enough to make the presense of dispatch unmeasurable. Paul Kienzle pkienzle at users dot sf dot net