Speeding up Python

Python, as an interpreted scripting language, is not characterized by speed or executive efficiency. A lot of utility tools like the package management tools, when written in Python, is not fast. Many tools have been rewritten using C/C++. Here are a few clues in terms of getting Python faster in many different aspects. This will be an on-going effort and updates will be published when there is new information.

Use Mamba to replace the original Conda (MiniConda)

We can either directly install the miniforge to replace the Conda package management system or we can replace the default Conda solver with the Mamba one.

Note that MiniForge is exactly the same as MambaForge now. Both use Mamba and Conda-forge as default.

From 2022.11, Conda also ships with a library called libmamba. So, Conda can also use the Mamba library directly.


# Update the conda in base environment
conda update -n base conda

# Install and set libmamba
conda install -n base conda-libmamba-solver
conda config --set solver libmamba

Use conda-forge repository

When use conda, specifically use conda-forge repository with -c conda-forge. This helps limit the search within this repository. For miniforge or mambaforge, they will use confa-forge by default.

If you are using conda instead of mamba, we can also change the default repository of conda from conda to conda-forge. See Conda documentation on channel management


## prioritize 'conda-forge' channel
conda config --add channels conda-forge

## Now, when you update all packages in base, it will use 'conda-forge' channel
conda update -n base --all