10 May
2012
10 May
'12
10:31 p.m.
On 10 May 2012 17:38, Campbell Barton ideasman42@gmail.com wrote:
If speed of class creation is important (as it is for us). suggest to call type directly rather then evaluating a string every time and executing it - this is one way.
/* always use O not N when calling, N causes refcount errors */ newclass = PyObject_CallFunction((PyObject *)&PyType_Type, (char *)"s(O) {sss()}", idname, py_base_class, "__module__", "bpy.types", "__slots__");
which is like doing this in python...
type(idname, (py_base_class, ), dict(__module__="bpy.types", __slots__=()))
Campbell,
Thanks for the hint. It's good to know how the type() should be called from C.
Best regards,
Mateusz Loskot, http://mateusz.loskot.net