Performance: do's and don'ts
Last updated on 2025-01-12 | Edit this page
Overview
Questions
- Can you give me some guiding principles on how to keep Julia code performant?
Objectives
- Identify potential problems with given code.
Type Stability
Callout
A good summary on type stability can be found in the following blog post: - Writing type-stable Julia code
Key Points
- Don’t use mutable global variables.
- Write your code inside functions.
- Specify element types for containers and structs.
- Specialize functions instead of doing manual dispatch.
- Write functions that always return the same type (type stability).
- Don’t change the type of variables.