-
Book Overview & Buying
-
Table Of Contents
Julia High Performance
By :
We discussed in the earlier sections that, when writing idiomatic Julia code, we should try and write functions with the minimum amount of type constraints possible in order to write generic code. We do not need to specify the types of function arguments or local variables for performance reasons. The compiler will be able to infer the required types. Thus, while the types are important, they are usually optional when writing Julia code. In general, bindings do not need to be typed; they are inferred.
However, when defining storage locations for data, it is important to specify a concrete type. So, for things that hold data, such as arrays, dictionaries, or fields in composite types, it is best to explicitly define the type that it will hold.
As an example, let's create two arrays containing the same data—the numbers one to ten, which are of the Int64 type. The first array we will create is defined to hold values of the Int64 type. The second is...