THIS IS NOT OFF TOPIC:) This is a critical issue that has impacts the design and implementation of any complex system attempted in Maya, using python. The limitations are significant and the penalties severe should one mis-step while developing in this area. If anyone has any other information regarding solutions or work-arounds I'd love to hear more. As it stands right now, we limit our use of python to non-computational purposes, or when computation is required, we limit the back and forth communication of python with the Maya API. When we need something done fast, we do it in a c++ plugin and expose what we need as arguments to a command, or inputs on a node. Again, very limiting and also not very portable, but in the end it yields a much more efficient result.
-Judah On Sun, Apr 17, 2011 at 5:19 PM, T. D. Smith <[email protected]> wrote: > > > On Apr 15, 2:55 am, Chad Dombrova <[email protected]> wrote: > > > this is getting a bit off topic, but if you're into ctypes, you should > check out cython. it's a python-like language that allows you to write > hybrid python and c code. it can be used for about any conceivable purpose > where python and c need to interact: c/c++ python bindings, fast compiled > modules, exposing python libraries to c, even statically typing pure python > code for speed. pretty slick and very easy to write. > > You're right that it's getting a bit off-topic, but I hope I'll be > forgiven another post in this direction. My problem with Python in > Maya right now is writing a deformer in Python. Maya allows you to > write plug-ins in Python, but it is very difficult to make them > efficient, even if you push all the heavy lifting onto C, using > ctypes, or something like cython/pyrex/etc. The basic problem here is > that you have to convert to CPython types in order to pass the data > along (unless you really do want to write an entirely new binding to > the Maya API,) and object creation/destruction with CPython is > insanely expensive- maybe 100 times too expensive for our purposes. I > would love to have our top-level deformer logic be in Python, and the > expensive bits be in C, or Pyrex, or cython, but just creating (and > destroying) the Swigged objects that the Maya Python API requires is > much more expensive than the very heavy math our deformer does in C. > > We've decided to ship our plugin in two pieces- a deformer in C/C++ > and the rest of what we do in Python that calls out to a C dll. You > seem very knowledgeable about this, so I wonder if you might know of > some way of passing data from ctypes, or cython, to Maya without > having to create all that expensive intermediate garbage. > > Thsnks > Tagore Smith > > -- > http://groups.google.com/group/python_inside_maya > -- http://groups.google.com/group/python_inside_maya
