I work for an engineering firm which builds most of our physics models in Excel with VBA. For myself and many other younger mechanical engineers in the company, this is not a good solution - we grew up with Python and Matlab and are more comfortable in those languages.
I've developed a script in Python to approximate the solutions to certain physics equations. I used a library called Pint to create each variable as an object containing both magnitude and a physical (e.g. foot, meter, kilogram) dimension. This let's me check that the correctness of my physics equations, which is extremely useful because a lot of physics errors can be caught by checking units. However, this leads to a lot of overhead (10x slowdown). As noted in a comment below, this is because Pint and similar libraries instantiate new objects every time an arithmetic calculation is performed.
Because myself and others will be frequently creating similar programs, I want want to create a process for ensuring that there are no unit errors in our programs (e.g., adding a [length] unit to a [time] unit, or failing to convert between Celsius and Kelvin). What approach can be used for this that do not incur excessive overhead?