Does GDScript compiler pre-evaluate constant expressions?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Charlie

I’ve been rooting around in code trying to answer this myself, but I’m a bit lost…

Let’s say I have an if statement like…

if declination > PI / 2.0:

…that gets tested some-god-awful number of times per frame. Should I define a constant HALF_PI, or is the GDScript compiler doing that before runtime anyway? If the latter, how would it handle expressions mixed with vars such as the following?:

x * (PI / 2.0)
PI / 2.0 * x
x * PI / 2.0 

(The first two should pre-evaluate PI/2. I believe the third should not.)