LumaPictures / pymel

Python in Maya Done Right
Other
492 stars 132 forks source link

pymel is using OpenMaya 1.0 API, 2.0 is reputedly much faster #31

Closed mjmvisser closed 9 years ago

mjmvisser commented 9 years ago

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, including slice support.
  • 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 rather than 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.

-- http://docs.autodesk.com/MAYAUL/2013/ENU/Maya-API-Documentation/python-api/

pmolodo commented 9 years ago

We'd love to migrate to the v2.0 api - it is, as you say, MUCH faster, and also a lot more intuitive. Hell, I'd switch just for not having to deal with MScriptUtil alone! Unfortunately, it was only ever really half finished, and development on it seems to have stalled. Many of the classes in the 1.0 api (including several key ones) were never migrated over. Plus, of course, it would be a fairly major undertaking...

Until it's more complete, there's no way we can migrate without breaking a lot of backward compatibility and losing a lot of features. So, closing this until it's been more fully implemented...

chadrik commented 9 years ago

Yup. 3 APIs to choose and none of them work right yay! On Sun, Jun 21, 2015 at 5:17 PM Paul Molodowitch notifications@github.com wrote:

Closed #31 https://github.com/LumaPictures/pymel/issues/31.

— Reply to this email directly or view it on GitHub https://github.com/LumaPictures/pymel/issues/31#event-336299241.

mjmvisser commented 9 years ago

Thanks Autodesk! (╯°□°)╯︵ ┻━┻