I have made a first attempt at getting libblender dynamic library to link and load in python (python outside of blender) with the help of IdeasMan, libblender.so can be compiled and loaded by both ctypes, and RPython rffi.  It looks like the remaining work of writing the wrappers around the C API is simple and just a matter of time.  The two issues i am having now hopefully are small and easy to fix.  1. WM_int segfaults, 2. many C headers are using some invalid syntax.<div>
<br></div><div>Issue1: both ctypes and RPython rffi will segfault, the blender window will appear for a split second before the segfault, so it looks like it should be an easy fix.</div><div><br></div><div>Issue2: This only applies to RPython, for some reason when a C header is included by rffi it compiles with some very strict syntax rules.  The compiler suggests some very minor changes to the headers, see the output below.</div>
<div><br></div><div>What is RPython?  RPython is a restricted subset of Python that is compiled to C by the PyPy translation tool chain.  It easily integrates with C, and gives you an interface that is many times faster than ctypes.  RPython is somewhere between 50-150x faster than normal Python, or about half the speed of hand optimized C.  </div>
<div><br></div><div>As soon as libblender is working better, RPython can be integrated into Blender without replacing the existing Python3 or bpy API.  Blender is a large and ever growing program, so where i think RPython would be ideal is in gluing all these C components together from the top down (from the mainloop downwards).  In this new model the structure of Blender changes from: C on top with Python underneath, to: RPython on top, C in the middle, Python on the bottom.  In the long term there could be big speed gains by using RPython and its integrated JIT generator, because Blender deals with a lot of runtime data and some of this could be constant folded by a JIT.</div>
<div><br></div><div>source code for test1:</div><div><a href="http://pastebin.com/SRKRPB17">http://pastebin.com/SRKRPB17</a></div><div><br></div><div>RPython rffi - header errors:</div><div><a href="http://pastebin.com/NA97TDDe">http://pastebin.com/NA97TDDe</a></div>
<div><br></div><div><br></div><div><br></div>