Is it possible for me to find the expensive functions(for example, A* pathfinding) in my pygame game and rewrite them as extensions as outlined here?
Is there a speed benefit to doing so? Is there a better (python) solution?
I ask this question because I have just started learning C for unrelated reasons, when it occured to me this might be a good idea when I go back to Python and pygame.
Is there a speed benefit to doing so?
It's impossible to say without knowing what it is exactly that you're doing, but the general answer is "very likely".
Is there a better (python) solution?
Again, it is impossible to say. Better than what exactly?
If you are working with numerical arrays, then the first step should probably be to use NumPy.
Once you've done that, there are multiple avenues for speeding things up other than coding extensions in raw C:
Finally, if you do find yourself writing C or C++ extensions, consider using SWIG or Boost.Python.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With