[Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray <=> numpy.array typemap to share?

Alexander Schmolck a.schmolck@gmx....
Sun Sep 23 12:37:26 CDT 2007

"Bill Baxter" <wbaxter@gmail.com> writes:

>> But say I want to pass a big matrix of datapoints to a classifier -- how
>> would
>> expression templates help here? Ublas does have various view objects, but
>> they're of limited usefulness, because they don't provide the same
>> functionality as the matrix class itself.
> What's wrong with using references?
> void my_classifier(BigMatrix& datapoints) {
>    ...
> }

Nothing, at least as long as its a const reference (I'm not sure the syntactic
pleasantness of non-const references are worth the additional
semantics-obscurification). But since this won't work for return values and
since having life-time management sounded useful I just pretty much went with
shared_ptr throughout. If even some semi-manual pseudo-gc scheme, like "smart"
pointers will essentially be zero performance overhead and no additional
headaches, because there are a few big matrices and no danger of cycic
structures, there didn't seem much reason not to use it. I'd just have
preferred it if I could have had this (i.e. memory managed reference
semantics) wrapped up more nicely without doing it myself (like in Qt's
container classes, which if I'm not mistaken either are reference semantics or


More information about the Numpy-discussion mailing list