Maya Python API 2.0
Overview
The Maya Python API 2.0 is a new version of the Maya Python API which provides a more
Pythonic workflow and improved performance. Both the new and old APIs can co-exist
in the same script but objects from the two different APIs cannot be used interchangeably.
The Python API 2.0 has a number of advantages over the original API:
- Array types are full Python sequences.
- Methods which take Maya array parameters will usually also take native Python sequences,
such as arrays and tuples. Exceptions are made in some case for performance reasons.
- The outputs of methods are usually returned in their return values, not through their
parameter lists. Exceptions are made in some cases for performance reasons.
- Methods which return multiple values (e.g. MFnFluid.getResolution) return them as
a tuple or list, eliminating the need for MScriptUtil.
- Object attributes are preferred over set/get methods. For example you can now write
array.sizeIncrement=64.
- There are more types of exceptions used when methods fail. Not everything is a RuntimeError,
as was the case in the old API.
- The new API is generally faster than the old. Up to three times faster in some cases.