4 ms·
Also note that the author asks for the native code for arguments of type `(AbstractString, Float64)`. The first is an abstract type — which means that this cod
by 3JPLW 10y ago
Also note that the author asks for the native code for arguments of type `(AbstractString, Float64)`. The first is an abstract type — which means that this code will never get called in the first place. Julia will resolve the type of the string, and then dispatch to the concrete implementation. Which, for an ASCIIString, is 3x shorter.
- vitaut 10y agoThis is actually a good point, but what about Unicode? Will `(UTF8String, Float64)` emit another function?
- 3JPLW 10y agoIt's the same on 0.4, and Strings are getting a big overhaul on 0.5. Here are the results for 0.4: $ julia -e 'f(a, b) = @sprintf("this is a %s %15.1f", a, b); code_native(f, (AbstractString, Float64))' | wc -l WARNING: Returned code may not match what actually runs. 628 $ julia -e 'f(a, b) = @sprintf("this is a %s %15.1f", a, b); code_native(f, (ASCIIString, Float64))' | wc -l 194 $ julia -e 'f(a, b) = @sprintf("this is a %s %15.1f", a, b); code_native(f, (UTF8String, Float64))' | wc -l 194
- vitaut 10y agoThanks, this looks better. I'll need to update the post.