[Bf-python] libblender (blender inside Python or RPython)

Goat Man goatman.py at gmail.com
Thu Sep 23 13:41:22 CEST 2010


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.

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.

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.

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.

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.

source code for test1:
http://pastebin.com/SRKRPB17

RPython rffi - header errors:
http://pastebin.com/NA97TDDe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20100923/a42ce561/attachment.html>


More information about the Bf-python mailing list