8
$\begingroup$

In putting together an answer to Changing Multiple Influences Simultaneously I came across the Slow python script warning in the drivers editor

Using a set up as outlined here driving a pose bone's constraint influence with the armature objects "prop" property

Using a traditional driver variable

enter image description here

And again using the use_self property of drivers. Since the drivers are on on pose bones, and the id data of a pose bone is the armature object then self.id_data is that object and self.id_data["prop"] (or self.id_data.get("prop", 0)) is the value of the custom property "prop" on that object.

enter image description here

However this displays the Slow Python Expression warning

What are the implications of this warning? How is it flagged?

Could be related: (possibly another question) how much of self is self... In trying to game the system with drivers tried to manipulate the self.children via a parent object driver, only to find the collection empty in the driver namespace. The method also flagged the warning

$\endgroup$
1
  • $\begingroup$ It's important to note that just like there's simple/slow differentiation, for slow (Python) there's also safe/unsafe. For a whitelist of allowed Python names and opcodes, see driver not working - using something outside of that list - like self - will require enabling script auto-execution. $\endgroup$ May 18, 2022 at 13:51

1 Answer 1

6
$\begingroup$

Expressions containing:

  • variable names: only ASCII characters.
  • literals: floating point and decimal integer.
  • globals: frame
  • constants: pi, True, False
  • operators: +, -, *, /, ==, !=, <, <=, >, >=, and, or, not,
  • conditional operator A if B else C
  • standard functions: min(), max(), radians(), degrees(), abs(), fabs(), floor(), ceil(), trunc(), round(), int(), sin(), cos(), tan(), asin(), acos(), atan(), atan2(), exp(), log(), sqrt(), pow(), fmod()
  • blender provided functions: lerp(), clamp(), smoothstep()

fall into Simple expression category and:

  • are evaluated directly, which improves performance on multi-core systems
  • are evaluated even when Python script execution is disabled
  • don't get the "Slow Python expression" flag
$\endgroup$
2
  • $\begingroup$ Would you consider it in many cases ignorable?, eg self.location.x gets the warning, making same as a variable (similar to above) doesn't. Not using self requires editing for each object copy to change variable target. Appears then any use of self in drivers requires the auto-run python scripts ..and hence slow warning if python is enabled. Cheers. $\endgroup$
    – batFINGER
    Nov 2, 2020 at 11:21
  • 1
    $\begingroup$ @batFINGER it depends, using the variable makes Blender treat it better and results in better multi-threaded performance, even though both are the same thing. If there are couple drivers like this it doesn't matter, but when there are hundreds, it may have some noticeable impact, I never encountered it though. $\endgroup$ Nov 2, 2020 at 22:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .