--
You received this message because you are subscribed to the Google Groups "pymel-dev" group.
To post to this group, send email to pyme...@googlegroups.com.
To unsubscribe from this group, send email to pymel-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pymel-dev?hl=en.
these are our best options:
1) educate users on efficient practices
2) add additional features to avoid wasted conversions, where possible
3) profile and look for inefficiencies
4) lobby autodesk for changes
for #2, one simple thing we could do is to create generator versions of common listing functions. since these only return results one-at-a-time, as they are requested, if you break out of a loop early, the remaining results are not cast to PyNodes. the problem is, how common is this really?
-chad
yes of course. essentially, if you'd like to convey this message, it all comes down to api to string conversions (and vice versa). every PyNode starts its life by acquiring an API object (for the reasons mentioned in the previous email). if it is instantiated from an API object then that is very fast -- many people don't realize you can instantiate a PyNode from an MObject, MDagPath, or MPlug -- however, if it is instantiated from a string, it's quite a bit slower.
the problem is compounded when we take this PyNode, which has already done the work of getting an API object, and we pass it to an API-ignorant function list listConnections. the PyNode must now use its API object to convert *back* to a string to pass to listConnections. the results from listConnections are also strings, which must be converted *back* to PyNodes.
if listConnections were API-aware, then POOF, no more conversions. API objects go in, API objects come back out. as an experiment, today i wrote a simple replacement for listConnections using the maya python API. in my test, it doubled the speed. not too shabby. the problem, as paul pointed out, is that these functions are exceedingly complex. we might be able to pull of listConnections, but cmds.ls is just too massive.
my success with listConnections today makes me hopeful that we could offer an environment variable to switch to these API-only alternatives, for the brave at heart. of course we will have tests in place for these functions, but i would still be very worried about replacing something as fundamental as listConnections without months of field testing. after all, tests are often a collection of things that went wrong, which are there to ensure that they don't go wrong again.
-chad