Jump to content
  • Advertisement
Sign in to follow this  

Python for logic, C for backend

This topic is 3083 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm interested in writing an engine where all the rendering and other engine type things are done in C and the game(s) would be written in Python. So, I'm wondering, would this be done best by wrapping a C DLL with ctypes or by writing Python plugin, or something else?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Uphoreum
I'm interested in writing an engine where all the rendering and other engine type things are done in C and the game(s) would be written in Python. So, I'm wondering, would this be done best by wrapping a C DLL with ctypes or by writing Python plugin, or something else?
There are a lot of solutions to this, and they all come with tradeoffs - here are a few popular options:
  • ctypes is probably the simplest, as it just requires minimal python wrapper code, but it is also by far the slowest to make function calls into C, and it isn't trivial to call Python from the C code.

  • boost::python is the most flexible solution for C++, and is pretty efficient, although the compiler and library setup can be a bit of a pain across multiple platforms.

  • SWIG lets you bind C/C++ to all sorts of languages (including Python), and generates fairly efficient wrappers, but requires pages of SWIG 'glue' to bind the C/C++ API.

  • Pyrex et al. allows you to write python extension modules in a hybrid python/C dialect, and produces efficient code, but can be problematic to interact with C++.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!