skip rna property & function lookups for members starting with "_" (since makesrna disallows this)

added a way profile python startup in bpy/__init__.py, if'd out by default.
This commit is contained in:
2009-11-14 23:11:46 +00:00
parent 33da66d7b3
commit d04f94d0c6
2 changed files with 33 additions and 17 deletions

View File

@@ -64,4 +64,14 @@ def load_scripts(reload_scripts=False):
print("Reloading:", mod)
reload(mod)
load_scripts()
if "-d" in sys.argv and False: # Enable this to measure startup speed
import cProfile
cProfile.run('import bpy; bpy.load_scripts()', 'blender.prof')
import pstats
p = pstats.Stats('blender.prof')
p.sort_stats('cumulative').print_stats(100)
else:
load_scripts()

View File

@@ -1379,7 +1379,10 @@ static PyObject *pyrna_struct_getattro( BPy_StructRNA * self, PyObject *pyname )
PropertyRNA *prop;
FunctionRNA *func;
if ((prop = RNA_struct_find_property(&self->ptr, name))) {
if(name[0]=='_') { // rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups
ret = PyObject_GenericGetAttr((PyObject *)self, pyname);
}
else if ((prop = RNA_struct_find_property(&self->ptr, name))) {
ret = pyrna_prop_to_py(&self->ptr, prop);
}
else if ((func = RNA_struct_find_function(&self->ptr, name))) {
@@ -1485,11 +1488,13 @@ static int pyrna_struct_setattro( BPy_StructRNA * self, PyObject *pyname, PyObje
static PyObject *pyrna_prop_getattro( BPy_PropertyRNA *self, PyObject *pyname )
{
char *name = _PyUnicode_AsString(pyname);
if(name[0] != '_') {
if (RNA_property_type(self->prop) == PROP_COLLECTION) {
PyObject *ret;
PropertyRNA *prop;
FunctionRNA *func;
if (RNA_property_type(self->prop) == PROP_COLLECTION) {
PointerRNA r_ptr;
if(RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
if ((prop = RNA_struct_find_property(&r_ptr, name))) {
@@ -1506,6 +1511,7 @@ static PyObject *pyrna_prop_getattro( BPy_PropertyRNA *self, PyObject *pyname )
}
}
}
}
/* The error raised here will be displayed */
return PyObject_GenericGetAttr((PyObject *)self, pyname);