[vtk-developers] Python wrapper code changed

David Gobbi david.gobbi at gmail.com
Wed Oct 6 09:21:53 EDT 2010


Hi all,

A couple days ago I pushed some changes that clean up the
python wrappers, the generated code has been dramatically
simplified and the monster vtkWrapPython.c file has been
reorganized and most of its utility functions have been moved
into vtkWrap.c and vtkWrapText.c.

The python-specific type conversions have been moved into
the file vtkPythonArgs.c so that they are no longer scattered
and duplicated throughout vtkWrapPython.c.

Since this was a reorganization, the list of new features is short:

1) Speed has improved, for most Set/Get methods the speedup
 is about 25%, and for some SetVector methods it is 10x faster.

2) All integer arguments are range checked, the old code was
 hit-and-miss with some types checked and some not.

3) Char arrays are properly converted.  So methods like
  vtkCharArray.GetValueRange() are finally useful because
  the returned python string will have the correct size, instead
  of being terminated at the first null.
  Similarly, vtkCharArray.SetTupleValue() will raise an exception
  if given a string of the wrong size.

4) In the docstrings e.g. what help(vtk.vtkMath) gives, square
 brackets like [ ] are put around array arguments for returned
 values.  So for vtkIdTypeArray you will see
   V.GetTupleValue(int, [int, ...])
   V.SetTupleValue(int, (int, ...))
 The square brackets mean that you should supply a python
 list or array (not a tuple) to accept the returned values.

A lot of the code has changed, so please let me know if anything
has broken.

   David



More information about the vtk-developers mailing list