Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Voilà, some static typing.
I chose to do this on world.py because this file contains what consumes most CPU (apart from pyglet).
According to cProfile, during the same in-game time (60 seconds of rendered game), and on the same (large) world, while flying on different directions to force hundreds of sectors to load and unload, and with VISIBLE_SECTORS_RADIUS = 16 and DRAW_DISTANCE = 120.0:
what was taking time:
Model.initialize:
during game:
For now, I think that the main part of the game is enough optimized. Of course, there is still some little annoying freezes, but they are mainly due to a bad synchronization between the rendering and the queue. I'll work on that later.
So this is good news, because even when asking hundreds/thousands of chunks updates to the game in one minute, we still have 8.5 % of the time that is spent sleeping.
When doing nothing, 57 % of the time is spent sleeping!
So have fun and develop lots of outstanding features, performance will follow :)