Any strategies for speading up compilation time?

I’ve been coding some gimmicks to parameterize my solvers and to avoid error due to missing settings (I’m using dolfin). To this aim, I’m using common python features, such as classes and dictionaries. I notice an increase in compilation time. Is it expected behavior? Would you have any tips and tricks to optimize code to shrink compilation time?

Some examples: I’m saving the traction vectors inside a dictionary; the stress tensors given by a hyperelastic constitutive model are stored in classes.

Thank you in advance

It is extremely difficult to give advice without a minimal working example.

The typical complaint regarding “long compilation times” arises from incorrectly compiling finite element formulations dolfinx.fem.form() inside for-loops.