I'm planning to create a game engine where Python will be the main scripting language, while the backend will be in C or possibly C++. I'm curious if I could write the entire engine using Cython to capitalize on its C-like performance while coding in Python, or if I should just focus on implementing the backend in C instead.
7 Answers
From my experience with Cython, I’d suggest going straight to C++. Cython is handy when you need to speed up a specific part of your program or if you want to interface with an existing C/C++ library, but for a game engine, you face some challenges. First, game engines have low latency needs—your main loop has to keep everything running in real time. Plus, the options for libraries are limited because the same latency issues apply. Lastly, you might struggle to find documentation for Cython related to game development, while C/C++ has more resources available.
Avoid trying to write the whole engine in Cython. Focus on using C/C++ for the core functionalities and create a clean API for Python using tools like pybind11 or the C API. Use Python for your gameplay scripts and keep the performance-critical sections in C/C++. That way, you get the best of both worlds.
Using Cython for specific parts of your game engine can give you C-like performance, but it’s best reserved for high-performance modules rather than as the foundation. Most game engines are built on a C/C++ backend and leverage Python for scripting and high-level logic.
There are a few examples, like 'Temple of Elemental Evil', that used Python for scripting, but Python isn't a common choice for game engines. Most engines prefer custom solutions or simpler languages, like Lua or GDScript.
Cython is more cumbersome than C; it's not quite the best of both worlds. I’d recommend just learning C. It’s a much more powerful tool for building performance-critical applications.
Honestly, I don't see many cases where Cython is the best option. Simple calculations can often be handled better with Numba, while more complex stuff usually belongs in C or C++ extensions. Cython can be tricky to optimize, and the learning curve is steep, so you might not gain that much speed.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically