[cctbxbb] controlling types over the C++/Python interface

Ralf Grosse-Kunstleve rwgrosse-kunstleve at lbl.gov
Mon May 14 07:15:30 PDT 2012


Hi David,

When I access the attribute in Python with the usual dot operator I get a
> tuple. What I'd really like though is an object of type <class
> 'scitbx.matrix.col'>, which is what I passed to the constructor of the
> object in Python.
>

This would be nice indeed but is a little tricky to implement. The C++
wrapper code would need to import scitbx.matrix. It's entirely possible but
I always shied away from introducing this dependency.


> I found I had to add
>
> from cctbx.array_family import flex
>
> to the package __init__.py where my C++ extension is imported,
>

This import piggy-backs a whole bunch of loosely related from-and-to-tuple
conversions; see scitbx/array_family/boost_python/flex_ext.cpp. I had long
discussions with Luc about this when he started using cctbx, because from a
purists standpoint centralizing all the conversions in flex_ext.cpp breaks
modularity. However, the discussions didn't lead to practical alternatives,
and I believe the current solution works well in practice.

Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://phenix-online.org/pipermail/cctbxbb/attachments/20120514/19711578/attachment.htm>


More information about the cctbxbb mailing list