UnderC binding

this just an idea that maybe can improve blender in many ways, before i continue i must warn you about my bad english :slight_smile: but i tried my best to explain it.

Python is great language, everything recently implement python as their scripting language, but there is couple things that could be improve with UnderC binding.

this couple things exist when we use Python under Blender:

  • using Python, we must make special code to communicate with Blender C function.
  • Python script get limited access to Blender Internal function, like GUI, etc.
  • Python script must be re-code to C before can be integrated to Blender source code.
  • Python speed can’t match up C (MakeHuman team reason change from python to C++)

UnderC is a fast C++ interpreter which implements a fair subset of the ISO standard. It does templates and exceptions, and a ‘pocket’ version of the standard library, complete with algorithms and containers. It is very easy to import shared libraries, including C++ classes.

UnderC is available under the GPL for Windows and Linux.
for complete information about UnderC check this site:
http://home.mweb.co.za/sd/sdonovan/underc.html
http://home.mweb.co.za/sd/sdonovan/faq.htm

i have been tried to benchmark UnderC and Blender Python using this code:

for UnderC:



#include "stdio.h"
#include "time.h"

int main()
{
double elapsedTime;
clock_t stopTime;
clock_t startTime = clock();

double X = 0.5;
for(int i = 0; i < 10000000; i++)
X = 1 + X * X;

stopTime = clock();
elapsedTime = (stopTime - startTime) / (CLOCKS_PER_SEC / (double) 1000.0);
printf("Elapsed time: %1.0f ms 
", elapsedTime);

return 0;
}


for Blender Python:


import Blender
import sys
import time

starttime = time.clock()
  
X = 0.5
for i in xrange(10000000):
  X = 1 + X*X
  
stoptime = time.clock()
elapsedtime = stoptime - starttime * 1000

print "Elapsed time:", elapsedtime

and the results is 5 ms for UnderC and 13000 ms for Blender Python
i’m not a Python coder so maybe my benchmark function was wrong, please correct me :slight_smile:

for the benchmark code i got from this thread
http://www.thescripts.com/forum/thread21516.html
and this link for time count code
http://www.osnews.com/story.php/5602/Nine-Language-Performance-Round-up-Benchmarking-Math-and-File-IO/page1/

so the idea is not to remove Python binding but to add UnderC binding, this will give alternative to scripter and which one they prefer to use depend the requirement of the script that they code.

maybe more competent Blender coder can help with this idea, is the UnderC can really benefit Blender or not? because i only Blender user with rusty C skill that have no idea about language binding to Blender :smiley:

just dream someday maybe Blender can have MEL or MaxScript emulator :rolleyes:

the difference is the complexity of the coding.

I know a lot of artists who are not coders, but will code in python to get things done, however the coding in UnderC looks a lot more complex than the other (i think this is the big issue)

but it does sound fairly impressive.

Alltaken

Uhm…seriously, that comparison is worth nothing. The clock() function is not very precise, in fact on windows the resolutions is like 15ms+.
Besides the fact that it’s pretty much impossible to do 10Mio multiplications with data dependency in that time, and since you never use X, the interpreter might just have optimized away the whole code!