Hi Ralf,
Thanks for the explanation. it's good to know what I shouldn't try to solve
a problem, as I now feel more freely able to get on with solving it :) In
this case the extra overhead of creating scitbx.matrix entities from the
returned tuples will disappear with time, as more code gets moved to C++.
So I must keep in mind not to worry about performance at the Python level.
I have a better feel for the type mappings now I think. Tuple as a common
type for all sequence-type objects makes sense in Python, and as long as I
can expect to get tuples back I can avoid any nasty surprises.
-- David
On 14 May 2012 15:15, Ralf Grosse-Kunstleve
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
, 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
_______________________________________________ cctbxbb mailing list [email protected] http://phenix-online.org/mailman/listinfo/cctbxbb