bpy/rna api class feature
- python defined classes will be used when available (otherwise automaically generated metaclasses are made as before)
- use properties rather then functions for python defined rna class's
- call the classes getattr AFTER doing an RNA lookup, avoids setting and clearing exceptions for most attribute lookups, tested UI scripts are ~25% faster.
- extending rna py classes this way is a nicer alternative to modifying the generated metaclasses in place.
Example class
--- snip
class Object(bpy.types.ID):
def _get_children(self):
return [child for child in bpy.data.objects if child.parent == self]
children = property(_get_children)
--- snip
The C initialization function looks in bpy_types.py for classes matching RNA structure names, using them when available.
This means all objects in python will be instances of these classes.
Python properties/funcs defined in ID py class will also be available for subclasses for eg. (Group Mesh etc)
This commit is contained in:
@@ -64,6 +64,7 @@ typedef struct {
|
||||
/* cheap trick */
|
||||
#define BPy_BaseTypeRNA BPy_PropertyRNA
|
||||
|
||||
void BPY_rna_init( void );
|
||||
PyObject *BPY_rna_module( void );
|
||||
void BPY_update_rna_module( void );
|
||||
/*PyObject *BPY_rna_doc( void );*/
|
||||
|
||||
Reference in New Issue
Block a user