[C++-sig] lvalue converter (and other) questions
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Sat Aug 31 01:58:16 CEST 2002
--- David Abrahams <dave at boost-consulting.com> wrote:
> > the moment (btw: the C++ language /really/ needs template typedefs):
>
> (btw: it's pretty hard to see why from your example)
Isn't
flex<ElementType>
a lot nicer than repeating
versa<ElementType, flex_grid<> >
all the time? With:
template <typename ElementType>
typedef versa<ElementType, flex_grid<> > flex;
> If shared<E> is already exposed via class_<>, it's already done.
> In which case, consider:
Note what this struct in the referenced code is doing:
template <typename ElementType>
struct shared_to_flex
{
static PyObject* convert(shared_plain<ElementType> const& a)
{
using namespace boost::python;
versa<ElementType, flex_grid<> > result(a, flex_grid<>(a.size()));
return incref(object(result).ptr());
}
};
It constructs a flex<E> from a shared<E> and then uses object() to wrap it up
for Python.
Can I have a class_<shared<E> > at the same time? How could bpl.so decide what
pops up the the Python layer? I want the flex<E>. flex<E> has a large number of
associated member/regular functions that I do not wish to bind another time for
shared<E>. Look at this file to see the damage:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cctbx/scitbx/include/scitbx/array_family/boost_python/flex_wrapper.h?rev=1.5&content-type=text/vnd.viewcvs-markup
Note that the entire file is one large template (well, one small and one
large). In addition there is the pickle suite (file names flex_pickle_*.h in
the same directory). Currently I use this to define eight Python types (bool,
std::size_t, int, long, float, double, std::complex<double>, std::string).
Sizes of the resulting flex.so/.pyd modules:
vc70, 800k
tru64 cxx, -O2, 12M unstripped, 11M stripped
linux gcc 3.0.4, -g, 80M unstripped, 6M stripped
And that is just the beginning. I still have a bunch of custom types to wrap.
While vc70 is very tame, I will have to buy an extra harddisk for my Linux
compilations if I duplicate everything for shared<E> and flex<E>. In addition,
at the Python level there is no point at all in having the two types. One is
better.
Thanks,
Ralf
__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com
More information about the Cplusplus-sig
mailing list