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
- Ofer
www.mrbroken.com
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
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.
--
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.
This is a 7 year old thread.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM9RXo%2BEHY0RV5whw0X4%3DGSco6JAJ%2Bu53dJsoLx_oJh_dDTygQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2gJ4RXpD_Q%2BP7uuF5yA6S9FDWve-Eg_duXfDDfLP-VYQ%40mail.gmail.com.
This is a 7 year old thread.
Sometimes it takes time to find the right words.