maya.cmds vs pymel speed?

1,603 views
Skip to first unread message

breeder

unread,
Oct 2, 2010, 11:08:55 AM10/2/10
to python_inside_maya
Hi
I did some test with maya.cmds as pymel , and result is that pymel is
slower.
For simple:
for i in xrange():setAttr
it is two times slower.
For expression i was testing it was 4-5 times slower that maya.cmds.
In my test i tried both "pymel.core.cmds" and PyNode method.

Is this "normal" thing for pymel to be slower that maya.cmds?

Thanks

"Sveinbjörn J. Tryggvason"

unread,
Oct 2, 2010, 12:12:46 PM10/2/10
to python_in...@googlegroups.com
Seems like it, I haven't tested it myself but according to Hamish
McKenzie(macaronikazoo.com) pymel is slower:

http://www.macaronikazoo.com/?p=271 and http://www.macaronikazoo.com/?
p=290

He has some excellent python related posts on his site btw.

-Sveinbjorn

> --
> http://groups.google.com/group/python_inside_maya

Jo Jürgens

unread,
Oct 2, 2010, 2:16:17 PM10/2/10
to python_in...@googlegroups.com
A node in maya.cmds is just a text string, while in Python it is a PyNode instance. Creating all those instances in PyMel does take time. For operations on large number of items where speed is crucial, I still tend to use maya.cmds.

breeder

unread,
Oct 2, 2010, 3:29:32 PM10/2/10
to python_inside_maya
Example:
import pymel.core as pm
pm.setAttr("locator1.tx",5)

So , in this example , does pymel use maya.cmds or is actually
creating PyNode for "locator1" and than setting attribute???

Paul Molodowitch

unread,
Oct 2, 2010, 4:21:45 PM10/2/10
to python_in...@googlegroups.com
For setAttr, it doesn't create a pynode... but the command is wrapped, so it will still be slower than the maya.cmds equivalent.
In general, though, speed is one are where PyMel still has a lot of room for improvement...

- Paul

Paul Molodowitch

unread,
Oct 2, 2010, 4:22:09 PM10/2/10
to python_in...@googlegroups.com
(err... that should have read 'area', not 'are'...)

- Paul

Ofer Koren

unread,
Oct 2, 2010, 10:36:21 PM10/2/10
to python_in...@googlegroups.com
pymel is more about the speed of coding, less about the speed of the
code... right Paul?

- Ofer
www.mrbroken.com

> --
> http://groups.google.com/group/python_inside_maya

breeder

unread,
Oct 3, 2010, 12:28:07 AM10/3/10
to python_inside_maya
Pymel is logical and excelent for coding and let you make complex code
easier.
But than ,this complex code is running slow.
Speed hit , at least for me is unacceptable.
I'm staying with maya.cmds untill(if possible) this speed problem is
resolved.




On Oct 3, 4:36 am, Ofer Koren <kor...@gmail.com> wrote:
> pymel is more about the speed of coding, less about the speed of the
> code... right Paul?
>
> - Oferwww.mrbroken.com
>
>
>
> On Sat, Oct 2, 2010 at 1:22 PM, Paul Molodowitch <elron...@gmail.com> wrote:
> > (err... that should have read 'area', not 'are'...)
> > - Paul
>
> > On Sat, Oct 2, 2010 at 1:21 PM, Paul Molodowitch <elron...@gmail.com> wrote:
>
> >> For setAttr, it doesn't create a pynode... but the command is wrapped, so
> >> it will still be slower than the maya.cmds equivalent.
> >> In general, though, speed is one are where PyMel still has a lot of room
> >> for improvement...
> >> - Paul

Count Zer0

unread,
Oct 3, 2010, 1:49:12 AM10/3/10
to python_inside_maya
Well put Ofer.

IMHO, the speed of coding in PyMEL FAR outweighs the lack of speed in
script execution. 99% of the time, script execution speed is near
instantaneous, so PyMEL is the proper thing to use.

When you get into lots of mesh iteration and weights stuff, you might
want to go back to maya.cmds or better yet get into Python API calls.
I think that stuff works even faster then MEL or maya.cmds, not as
fast as compiled API, of course.

Chad confirms this at the bottom of this thread:
http://forums.cgsociety.org/archive/index.php/t-833446.html

-jason

On Oct 2, 7:36 pm, Ofer Koren <kor...@gmail.com> wrote:
> pymel is more about the speed of coding, less about the speed of the
> code... right Paul?
>
> - Oferwww.mrbroken.com
>
>
>
>
>
>
>
> On Sat, Oct 2, 2010 at 1:22 PM, Paul Molodowitch <elron...@gmail.com> wrote:
> > (err... that should have read 'area', not 'are'...)
> > - Paul
>
> > On Sat, Oct 2, 2010 at 1:21 PM, Paul Molodowitch <elron...@gmail.com> wrote:
>
> >> For setAttr, it doesn't create a pynode... but the command is wrapped, so
> >> it will still be slower than the maya.cmds equivalent.
> >> In general, though, speed is one are where PyMel still has a lot of room
> >> for improvement...
> >> - Paul

Paul Molodowitch

unread,
Oct 3, 2010, 3:58:54 AM10/3/10
to python_in...@googlegroups.com
Yes, Ofer is basically right, in that pymel's priority has always been ease of use over execution speed.  If execution speed is your thing, then pymel probably isn't the right tool for the job.

Having said that, though, I would like to take a look at what can be done to try to speed up pymel at some point...

- Paul

John Creson

unread,
Oct 3, 2010, 9:55:58 AM10/3/10
to python_in...@googlegroups.com
There are seldom areas where scripts' speeds actually impact the job
you are doing.

Yes, there are things I can do to really slow down my scripts (lots
and lots of prints statements perhaps?), but if our scripts are
working efficiently, they will be using Maya to do the heavy lifting,
not the scripting.

Something that PyMEL has helped us accomplish, and has helped with a
specific known speed issue, is the ability to pass a selection as an
mObject, rather than converting it to a string, passing the string and
then converting back to an mObject. (kind of like the lots and lots of
prints statements above, only applied to how commands communicate
their results to the next command) This can be really important when
the names of the selections need to be really long because there are
many levels of hierarchy and the objects have been duplicated many
times.

Also, as suggested, taking advantage of python enabled API queries is
fast and safe, and PyMEL has built this into normal scripting
situations. You don't have to do anything special to take advantage
of this other than use PyMEL, API opportunities are built in. (and
it's a great place to look to see how it's done, in case you'd like to
work out how to make things faster in this way)

Along the lines of passing strings into commands...
The example is doing just that:

pm.setAttr("locator1.tx",5)

whereas, if you built the locator in your script, assigining it to a
variable, and then set that attr using the variable, then you should
avoid needing to convert the string to the mObject.

myL = pm.spaceLocator()
pm.setAttr(myL.tz,5)

Also, perhaps you are also seeing the time it takes to do the first
part in the example:

import pymel.core as pm

It takes a little time to import pymel. It's doing a lot. It should
not be factored into performance tests.
This part is done once in Maya(like starting Maya), and could be put
into your userSetup.py to make it more invisible.

If you use PyMEL, you don't tend to use it as a one-off here and
there, you tend to work with it to accomplish a major task, or in a
series of inter-working tools. The more you use it, the more
opportunities it has to save you time at runtime, as well as during
development.

-JohnCreson

> --
> http://groups.google.com/group/python_inside_maya

mtherrell

unread,
Nov 18, 2017, 3:08:18 AM11/18/17
to Python Programming for Autodesk Maya
wow.. ok its 2017.
here is what i think about pymel:

PyMel rant: Pymel allows for more concise, less terse (efficient yet legible) code. It allows faster turn around
time on more complex problem solving by a majority of people, (with the exception of a few clerical savants out
there who have wrote-memorized the entirety of mel). It gives standardized OOP "dot" notation access,
simultaneously, to both the mel commands layer and API via its well organized, well conformed methods and attributes
belonging to PyNodes. This reduces having to remember or research the large variety of argument structure and
command names that have accumulated in both mel and the Maya API over the years. (too bad those were not designed
that way to begin with, and that stuck with.. ok remember that for the next big tool).

Pymel is not a toy, and is used for serious studio pipeline by big boys and girls. It does have an irrelevant
trade-off in speed vs. cmds, (some folks can't see past that unfortunately, particularly the clerical savants)..
nevertheless, PyMel can often be written to be faster than its cmds counterpart when using the API access that it
possesses. Ultimately, the eval speed of Pymel vs cmds is a moot point, because it is more than adequate, even at its
slowest, for its targeted use-cases, added to the time saved in code-comprehension by new comers to the pipeline,
and iteration time improving or inventing new pipeline. O.K. rant over.

damon shelton

unread,
Nov 18, 2017, 7:05:49 PM11/18/17
to python_in...@googlegroups.com
Yes it is expected that pymel is slower as most of the work is wrapping cmds and Mel. So most code is evaluated double. 

--
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/d6809362-bdf7-4e36-ae08-295bda5bc8bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Justin Israel

unread,
Nov 18, 2017, 8:24:57 PM11/18/17
to python_in...@googlegroups.com

Simon Payne

unread,
Nov 19, 2017, 4:01:26 AM11/19/17
to python_in...@googlegroups.com
Lol. Indeed. I look forward to the tenth anniversary of “mc v pymel speed?” 🙂 Should be commemorated in a few years time with a golden maya manual, a leaflet reminding everyone that Autodesk/which ever owner - did not invent pymel and a large slice of red princess cake with a big black ‘M’ on the top 🙂

Sent from my iPhone

Marcus Ottosson

unread,
Nov 19, 2017, 5:00:22 AM11/19/17
to python_in...@googlegroups.com

This is a 7 year old thread.

Sometimes it takes time to find the right words.

Reply all
Reply to author
Forward
0 new messages