Book Image

Practical Maya Programming with Python

By : Robert Galanakis
Book Image

Practical Maya Programming with Python

By: Robert Galanakis

Overview of this book

Table of Contents (17 chapters)
Practical Maya Programming with Python
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Improving the performance of PyMEL


I hope at this point, PyMEL's superiority over maya.cmds has been thoroughly demonstrated. If you have any doubt, feel free to rewrite the examples in this chapter to use maya.cmds and see how much cleaner the PyMEL versions are.

Having said that, PyMEL can be slower than maya.cmds. The performance difference can usually be made up by applying one of the following three improvements.

Defining performance

For most scripts, the performance difference is too miniscule to matter. Fast and slow are relative terms. The important metric is fast enough. If your code is fast enough, performance improvements won't really matter. Most of the tools you will write fall under this category. For example, making a pose mirroring tool go 500% faster doesn't matter if it only takes a tenth of a second in the first place.

Refactoring for performance

In most cases where PyMEL code actually needs to be sped up, rewriting small parts can make huge gains. Is your code doing unnecessary...