[vtk-developers] Python wrapping & factory methods

Timothy Shead tshead at sandia.gov
Tue Apr 26 15:39:11 EDT 2011

I'm troubleshooting a reference-counting issue in the Python bindings 
for VTK - in a nutshell, the only way to instantiate vtkArray-derived 
classes from Python is through the vtkArray::CreateArray() static 
factory method (because vtkArray derivates are template classes).

However, using vtkArray::CreateArray() from Python returns objects that 
have a reference-count of 2, because the Python wrapping code increments 
the reference-count of objects returned from "normal" class methods. 
This leads to annoying leaks when the program ends.

 From what I can see, there's a separate code path when instantiating 
VTK objects from Python.  I'm thinking that there must be other examples 
of factory methods in VTK, and that there must be some clean way of 
using them from Python?

Thanks in advance,

Timothy M. Shead
Sandia National Laboratories
1461, Scalable Analysis and Visualization

More information about the vtk-developers mailing list