Python SOP vs VOP SOP – and the winner is …

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.

OTL   |   HIP

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.

Conclusions:
If you want speed, use VEX.
If you need recursion, use Python.

 

7 thoughts on “Python SOP vs VOP SOP – and the winner is …

  1. Pingback: rpg game gold

  2. You forgot to mention one more difference between the two.
    While in Python you can manipulate and create new data, like for example you can simply create a point
    in VEX you can not create anything, it only allow you to manipulate the current data.
    A small detail but worth a mention! 😉

    • Sorry for the late reply. I didn’t know I had to approve the message posted to my web page 🙂 I just found your message.

      Good call about the difference between python and vex !
      By the way, now In Houdini 13 you can create new data even with Vex (cvex context) and it’s freaking fast !

  3. Hi there! I understand this is somewhat off-topic however I needed to ask.
    Does running a well-established website such as yours require a massive amount work?
    I’m brand new to running a blog however I do write in my journal everyday.
    I’d like to start a blog so I will be able to share
    my own experience and feelings online. Please let me
    know if you have any kind of ideas or tips for brand new aspiring blog owners.

    Thankyou!

    • hi Swarovski,
      sorry for the late reply.
      To set up a website like this doesn’t take a huge amount of work.
      All you need to do is buy a domain name and a buy some hd space on some web server. I use http://www.siteground.com, they’re pretty good.
      Then you need to install a web app (a premade – customizable web site), like Joomla or WordPress, they are both free and allow a large degree of customization. Once you install on your website one of those web apps, you can choose between hundreds of pre-made web pages and customize them with your logo, images, and content.
      It’s pretty simple really, it might take about 2/3 days.
      I hope this helps 🙂

  4. Well, VEX is not a scripting language despite the fact it is an interpreted one. VEX is a DSL and as a DSL it is more suitable for certain things. In our case it’s processing of geometry attributes, pixels of image or shading samples at render time.
    It’s not only faster than Python but also is easier to use and has some tools which are not accessible from Python (for example, point cloud functions).
    VEX from version 12.5 allows recursion through the shader calls. Not sure what are the limitations but this kind of thing is possible:

    [code]
    cvex fib(int i = 0; export int rval = 0)
    {
    if (i >= 2)
    {
    int v1, v2;
    fib(“i”, i-1, “rval”, v1);
    fib(“i”, i-2, “rval”, v2);
    rval = v1 + v2;
    }
    else
    rval = i;
    printf(“%d: %d\n”, i, rval);
    }
    [/code]

    Since version 13 certain contexts of VEX allow not only to change the data but also to add / delete the data. For example AttribWrangle SOP context allows to do something like removepoint(geoself(), 23); // remove point No 23
    So…

    • thank you for your comment mr H !
      This post was created unfortunately in May 2013, at that time there was no chance to add or destroy data via Vex 🙁
      Actually I was not aware of the recursion thing, I’ll definitely try it out, thank you for pointing it out H !

Leave a Reply to admin Cancel reply

Your email address will not be published. Required fields are marked *