7
$\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$
5
$\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 '20 at 11:21
  • $\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$ – Jaroslav Jerryno Novotny Nov 2 '20 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.