Is pyMEL slower than MEL? Why PyMEL?

352 views
Skip to first unread message

ssscr...@gmail.com

unread,
Sep 18, 2014, 5:58:11 AM9/18/14
to python_in...@googlegroups.com
Hi pyGeeks & pyNERDS out there :)

I salute you all. Knowing Python(an OK scripter) I have started learning Maya scripting from MEL and now gravitating towards pyMEL as I feel thats the way to go.

I also want to know the cons of pyMEL over Python in Maya & MEL ofcourse. Please refer the following link and this gentleman says pyMEL is slower than MEL.

http://jeremyyk.com/tutorials/maya-s-python-api-2-0-

Could somebody motivate and justify me that pyMEL is the future & the way to go :)

I appreciate your time.

Solomon.

Justin Israel

unread,
Sep 18, 2014, 7:47:52 AM9/18/14
to python_in...@googlegroups.com

I think there are valid points in that post.
MEL is still fast, though annoying to write.
PyMel is an abstraction over both the python commands and Maya API. And PyMel can be both it easier/shorter to write, and can be slower than the pure Python API.

You would just need to explore these areas for yourself to get a better understanding of the pros and cons. If you ask one guy he might say he swears by PyMel. If you ask another, he may have reasons for sticking with the direct python APIs. Not sure how many people still stick with Mel anymore. Generally either python is fast enough or you write a C++ plugin.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/5a3e22a3-afce-4142-8457-660b6f098f3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marcus Ottosson

unread,
Sep 18, 2014, 7:48:13 AM9/18/14
to python_in...@googlegroups.com
Hi Solomon,

In a nutshell, PyMEL results in less lines of code at the expense of being more heavy to compute. So its a trade-off between readability and performance. Depending on your needs, one is typically more suited than the other for certain tasks. As an example, you might not write a deformer using PyMEL, but you might write a scene saver.

Best,
Marcus

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/5a3e22a3-afce-4142-8457-660b6f098f3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Hans Baldzuhn

unread,
Sep 18, 2014, 7:52:09 AM9/18/14
to python_in...@googlegroups.com
PyMel is far slower than mel or default python.

As Jeremy YK, pyMel is a wrapper of the python and maya api.
If you are using api calls on a single object (like querying vertex position etc), it will as fast as the python API.

But for everything accessible through mel, like the "ls" command, pymel can be up to 40 times slower on huge scene (from my experience). There is a big overhead of wrapping all returned strings to PyMel nodes.

For me it's only a way to write faster and in a more pythonic way. But it's going to be always slower than mel, python or API.  And it's HUGE to load.
I personally just need it to be fast so pymel is useless to me.

In my codes, I finally removed all pymel call with default python command, and I made a simple node wrapper to keep a few pymel functionality.

Geordie Martinez

unread,
Sep 18, 2014, 12:35:42 PM9/18/14
to python_inside_maya
Honestly you should learn maya.cmds and PyMEL. You need to know both because studios use both. and you can't get away with just knowing one.
Then learn the Python API

PyMEL saves you coding time not cycles.  if you're writing a deformer or iterating over the verts in a poly mesh you'd want to use the Python API.
if you're rigging I prefer PyMEL.

PyMEL is object-oriented. It's a framework wrapper that wraps MEL, maya.cmds and the Python API. Which ever route returns the fastest most-complete data is what PyMEL will use.

for rigging or general scripts PyMEL is great! I've used it for years.
For code that needs to be super fast and deals with gigantic data sets, use the Python API or C++ API.

RE the ls command being 40x slower in PyMEL is a faulty comparison. Here's why:
the pymel selected() command is slower because each item it returns is converted to a pynode object instead of a string (maya.cmds).
What is returned is more useful, but you have to wait a millionth of a second longer to get it.

if you are a python coder, PyMEL will behave as you would expect. Like other python modules in the python universe. It is more pythonic as it passes around objects with function sets related to the object. instead of strings that force you to search for the right methods.

therefore you can run help on any PyMEL object and see a list of methods. This is pythonic.
help(pynode)
or
help(pynode.__class__)

the Python API 2.0 is not as complete as the 1.0 API and is incompatible with the 1.0 API.

Perhaps soon the 2.0 API will be fully functional.







--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

Jeremy YeoKhoo

unread,
Sep 19, 2014, 3:23:29 AM9/19/14
to python_in...@googlegroups.com
I thought the API 2.0 just handles the basic data types (ie strings, arrays), so we would'nt have to bother about MScriptUtils and SWIG stuff. I don't think it holds a good pythonic paradigm as pyMel does. I do think pyMel is great, but honestly I don't use it that often. I dabble a little between writing simple python plug-ins and mel and I need to sometimes create an impromptu function and just didn't want to get too comfortable in the logic of pyMel. 
Reply all
Reply to author
Forward
0 new messages