Performance tips

Throughout this book, we paid attention to performance. Here, we summarize some of the highlighted performance topics and give some additional tips. These tips need not always be used, and you should always benchmark or profile the code and the effect of a tip, but applying some of them can often yield a remarkable performance improvement. Using type annotations everywhere is certainly not the way to go, Julia's type inferring engine does that work for you:

  • Refrain from using global variables. If unavoidable, make them constant, or at least annotate the types. It is better to use local variables instead; they are often only kept on the stack (or even in registers), especially if they are immutable.
  • Structure your code around functions ...

Get Julia: High Performance Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.