I am writing a hull-wave simulator for the design of boat hulls as they are affected by waves. This application is composed of 2 main parts, the part that renders the waves and its impact on the hull, and a GUI that controls the hull shape, waves, and other factors. The two parts of the application will need to exchange data, for example, the GUI will set the hull shape and this will be displayed by the renderer. The renderer will show the waves and it will tell the GUI statistics about the waves as they are being animated. This application will run on Windows.

The Renderer part of the application must be written in C because it needs to do very fast numerical calculations and requires the use of OpenGL and must render very quickly. The GUI
part of the application will be wxPython.

The options for constructing the application that I have thought of are:
1) The wxPython part launches the Renderer on a thread, and the Renderer is a DLL
(provided a DLL can display graphics).
2) The Renderer starts a thread where the Python interpreter is embedded, which launches
wxPython.
3) The Renderer and the GUI are actually two separate applications that communicate with each
other over a socket.

My last resort is Option 3 because communications can be a hassle.
Option 1 seems to be the easiest but will be very difficult to debug the Renderer using my
IDE because it is a DLL, if a DLL can display graphics at all.
Option 2 seems to be the most feasible both in terms of debugging and displaying graphics.

I have concerns about the Python GIL and how that will affect the way this program will work. The Renderer is going to be running a tight loop. The GUI under wxPython also runs a main loop internally, but has the ability to put function calls on a sort of stack to be executed
without interrupting its main loop.

In my experience implementing Option 1 in another project, I know that Python suspends execution until the DLL function calls return, but I did not launch the DLL on a thread. I expect that if the DLL were launched on a thread, a function call into the DLL will still
suspend Python.  Maybe someone can tell me if this is true?

Option 2 is of most interest to me, but how shall I handle the Python GIL when the Renderer runs its main loop? Will the main loop be unaffected because Python interpreter is embedded
in a thread?

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to