PyMel in Maya Python

PyMel is absolutely the way to go if you are going to program tools and pipelines in Maya Python.
Let me show you why I prefer it over maya.cmds.

Object Oriented vs Procedural

I think the below example illustrates the usage difference perfectly. In the comments, I am only stating what I experienced myself when switching from MEL to PyMel in 2009.


  • Object oriented – results in code that is shorter and more readable.
  • Open source and maintained on GitHub
  • Wraps all MEL commands
    • It also contains everything maya.cmds does so you can mix and match between procedural and object oriented – if you want to.


  • Procedural
  • Maintained privately by Autodesk
  • Wraps all MEL commands

Some more examples

If you just overview the following 2 code sections, you get a glimpse of what your code files will start to become. You write a ton of code right?



The cost of awesome

The casting the pymel does to create the internal link to dag object has a slight performance cost.

Justin Israel set up a test that he recently ran in Maya 2015. The test iterated over 20 000 verts and transformed each slightly. Below you can see the results:

  • Python API – 0.2959 sec
  • maya.cmds – 0.5757 sec
  • pymel – 1.6670 sec

What I do 99% of the time when writing tools, is casting way less than 20 000 api connections via PyMel, so for what you get, I would say that this cost is negligible, but it is good to be aware of in case you need to iterate 100k+ verts – you should do this via API….

Spread the knowledge

About the Author

Christian Akesson

Facebook Twitter Google+

Senior Technical Artist at Amazon Game Studios. Maya user since beta 1 in 1999. Mostly in Houdini these days...