0
$\begingroup$

To improve runtimes, I am trying to avoid using operators that lead to scene updates.

See here for the background:

Python performance with Blender operators

Why avoid bpy.ops?

Finding vertices in a Vertex Group using Blender's Python API

When I know more, I will find a low-level way to avoid the use of the relevant operators.

Do I need to avoid all uses of bpy.ops... or is it only operators that add something new to the scene?

Are there any operators to avoid that are not bpy.ops...

Are there other ways to avoid scene updates, such as using bmesh, other libraries, or explicitly stopping the updates? I would then just have the one scene update when I need it.

Can I avoid scene updates by hiding objects from view? I do not need to see objects being used in Rigid Body physics for collision detection, but perhaps the physics world needs a scene update in every frame!

$\endgroup$
2
  • 2
    $\begingroup$ From experience I can tell that using operators is not necessarily "slow", that's a general misconception and not always true, just depends on the case. Have a look into the source and/or measure the execution time per operator. AFAIK there is no direct way to avoid scene updates if the operator updates the scene... Notice that C is not the slowest language in the world, some operators are written in python and it's pretty hard to beat their execution time. Suggest add more details and what you'd like to do, there are quite a few operators to test. $\endgroup$
    – brockmann
    May 19, 2021 at 17:58
  • $\begingroup$ The saying about premature optimization being bad might apply here. Instead of spending a lot of effort to avoid all operators or figuring out in advance which ones are "slow", you might have a better time using just them where convenient and then making low-level replacements for some of them if and only if (1) your script starts to actually have performance issues and (2) profiling traces those issues to operators that are feasible for you to replace with faster code. $\endgroup$
    – Will Chen
    May 20, 2021 at 0:20

0

You must log in to answer this question.

Browse other questions tagged .