Does adding "-> void" after functions improve GDScript speed?

Godot Version



Just wondering if there is a speed boost to writing “-> void” at end of functions that don’t return anything?

I have a lot of code migrated from before static typing in gdscript and don’t want to add this everywhere if there isn’t a speed boost.


Apparently Yes.

I’m not sure if I see what you’re seeing here…

Don’t find any mention of return void giving speed increase

Scroll down to the very bottom: “Static types improve GDScript performance and more optimizations are planned for the future.”
But I still use dynamic typing for convenience. The speed boost is hardly recognizable in small projects.

for void specifically it likely doesn’t allow for any extra optimization assuming you aren’t using the function in any expressions (which you shouldn’t be if it never returns a value) it should already be efficient without a return type on the function.

It does help by helping gdscript give you better errors and warnings to help notice when you’re expecting a return but it doesn’t return anything or the function shouldn’t return anything but in actuality it does

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.