No. Giving types in function definitions does not give you any speedup as
the function are always compiled for concrete types.
When you define composite types it is however important to give concrete
types for optimal performance.
Am Donnerstag, 23. Januar 2014 00:41:41 UTC+1 schrieb Patrick Foley:
>
> Thanks!
>
> I've sorted it out and have solved my original problems.
>
> Would I get any speedup by defining
>
> function foo{TA<:Real, TB<:Real}(a::TA, b::TB)
>
> rather than
>
> function foo(a::Real, b::Real)
>
> ?
>
> My guess is .. yes? Since if I'm defining it the first way, I can compile
> versions of foo like foo(a::Int8, b::Int8) automatically, which would be
> much faster than defaulting to a foo(a::Real, b::Real) and reserving space
> for a possible Float64 each time?
>
>
> On Tuesday, January 21, 2014 7:17:36 PM UTC-5, Patrick Foley wrote:
>>
>> Is there a way to get around this? I have a lot of types (foo1, foo2,
>> ....) all of which are subtypes of an abstract (bar). I want to be able to
>> define the behavior for arrays of any of the foos just by defining the
>> behavior of an array of 'bar's. Any advice?
>>
>