I’ve played a bit with Python Sops , Vex sops, and Vop Sops.
Python sops are a really powerful tool cause they allow using Python !! Which is a way more complete scripting language than VEX. And yes, I am talking above all about….recursion !
Now, the power of Python comes to a big price compared to VEX: performance.
In order to quantify how slower a python script might get, compared to the identical Vex version I created a simple Python Sop to calculate the closest point on a surface , given a bunch of points in the world space (a very dense grid in the example), and an SDF (this can be a volume or a vdb sdf, it doesn’t make much difference).
Check it out yourself:
Don’t forget to install ths OTL in your favorite otl scan path.
In case you’re one of those who have no patience…in this specific case the winner is VEX because it’s like 20 times faster, as you can see from the hip file.
Why VEX is it faster ?
- it allows multithreading
- it’s a SIMD (single instruction multiple data , scripting language)
- it doesn’t have the overhead loading times of importing Python libraries
Why sometimes Python is better ?
- because of the same reason anyone might use Python as a scripting language
- because differently from VEX, it allows recursion
- you have much more freedom than VEX since vex is just a huge point loop and has many restrictions that come with it.
If you want speed, use VEX.
If you need recursion, use Python.