PyAPI: optimize depsgraph use in PyDrivers

Avoid re-creating & freeing the depsgraph for every driver evaluation.

Now the depsgraph is kept in the name-space (matching self),
only re-created when the value changes.

In a contrived test-case with many drivers this gave ~15% overall
speedup for animation playback.
This commit is contained in:
2022-03-08 22:07:59 +11:00
parent f76f48be23
commit 73dc8c24e4
3 changed files with 41 additions and 38 deletions

View File

@@ -14,7 +14,7 @@
#include "BLI_utildefines.h"
static PyObject *bpy_intern_str_arr[16];
static PyObject *bpy_intern_str_arr[17];
PyObject *bpy_intern_str___annotations__;
PyObject *bpy_intern_str___doc__;
@@ -31,6 +31,7 @@ PyObject *bpy_intern_str_frame;
PyObject *bpy_intern_str_properties;
PyObject *bpy_intern_str_register;
PyObject *bpy_intern_str_self;
PyObject *bpy_intern_str_depsgraph;
PyObject *bpy_intern_str_unregister;
void bpy_intern_string_init(void)
@@ -58,6 +59,7 @@ void bpy_intern_string_init(void)
BPY_INTERN_STR(bpy_intern_str_properties, "properties");
BPY_INTERN_STR(bpy_intern_str_register, "register");
BPY_INTERN_STR(bpy_intern_str_self, "self");
BPY_INTERN_STR(bpy_intern_str_depsgraph, "depsgraph");
BPY_INTERN_STR(bpy_intern_str_unregister, "unregister");
#undef BPY_INTERN_STR