Which is faster : if (bool) or if(int) Godot

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

As far as I know bool is a different size? And how do I understand gdscript is not fully compiled and translated into byte code? Is there any article about gdscript? As work is when compiled with aes ?

I can’t answer your question, but you can find some infos about GDScript here.

DodoIta | 2018-06-26 11:19

:bust_in_silhouette: Reply From: Zylann

To answer the question, I think none of those will make a difference in execution speed. GDScript is compiled to interpreted bytecode. If you desperately need to know, you can run such if billions of times and see which one wins, but I don’t think it will make a difference overall.

Technically, bool is smaller than int, but in GDScript variables are Variant internally, and Variant has a fixed size large enough to contain any value type handled by the engine (around 20 bytes, as explained here: Variant — Godot Engine (3.0) documentation in English)