Import order: from the most general packages to the most specific ones, or the opposite (or it doesn't matter ?)

When you need to import several packages, and you believe that there is some inner dependency between them, do you start importing the general ones first or the specific ones first, or it doesn’t matter ?

eg:

import Downloads, Random
import DataStructures
import StatsBase
import HTTP
import Tables
import CSV 
import Distributions
import DataFrames
import GeoDataFrames
import Colors
import Plots
import StatsPlots
import NCDatasets
import Rasters

or

import Rasters
import NCDatasets
import StatsPlots
import Plots
import Colors
import GeoDataFrames
import DataFrames
import Distributions
import CSV 
import Tables
import HTTP
import StatsBase
import DataStructures
import Downloads, Random

?

It doesn’t matter. Repeated loading will not happen anyway. Alphabetical order may be a good choice.

Potentially the order could affect how much invalidations and thus recompilation you run into, I suspect, but I have no idea whether there’s a systematic way to optimize that.

1 Like

yes, I was thinking about that…