[C++-sig] Custom from-python converter (almost working)

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Fri Dec 5 18:42:45 CET 2008


> void

> p(vec3f *v)
> {
>     printf("%f, %f, %f\n", v->x, v->y, v->z);
> }

This is indeed not supported, since it would require "converters with write-back".

vec3f const* v

should work, but

ve3f* v

doesn't because the missing const indicates that you want to modify the pointee in place.
For a Python tuple this can definitely not work since tuples are immutable.
It could in theory work for a Python list, but Boost.Python doesn't support this.
A few years ago we had extensive discussions about this, but it was too hard to
implement.

Ralf

P.S.: I'm using this seasoned file for all "list/tuple/iter <-> small C++ array" conversions:

http://cctbx.svn.sourceforge.net/viewvc/cctbx/trunk/scitbx/boost_python/container_conversions.h?view=markup

Probably, all you need is

  tuple_mapping_fixed_capacity<vec3f>


More information about the Cplusplus-sig mailing list