It's funny you should mention this.

One of the things I realized after SciPy this year is that there is a 
lot of interfacing of Numpy with C++ (as opposed to C) that could really 
benefit from a standard C++ wrapper around Numpy.  A bunch of different 
projects all had home-grown, semi-complete solutions. 

A standard wrapper would be good for all of the reasons you mention 
(basically resource management), but also to have a cleaner syntax for 
accessing the elements that would abstract away striding, ordering etc.  
It may actually be possible to build it around boost::multiarray (the 
closest thing the upcoming C++-0x standard has to a n-dimensional array).

Can't imagine I'll find time for it anytime soon, but it would be fun to 
work on...

Cheers,
Mike

Christopher Barker wrote:
> Michael Droettboom wrote:
>   
>> I think we want to use std::vector where possible for new code, and 
>> convert as we go through old code.  Manual malloc/free is just too error 
>> prone.  (We're forced to do some by interfacing with Python, but it 
>> should be kept to a minimum).
>>     
>
> My understanding is that this is exactly the issue -- with std::vector 
> and friends you can't both get the data pointer and create a vector with 
> a data pointer, which would be what you'd want to do to interface 
> efficiently with numpy arrays.
>
> I've been looking for a way to address this problem, but my C++ is 
> pretty week. maybe smart pointers and/or other boost classes could help.
>
>
> I do have an idea, though. The goal is a set of classes for working with 
> data that are convenient to use with pure C++, but also play with numpy 
> arrays.
>
> I imagine a simple vector/array set of classes build on top of a simple 
> object: a reference counted data block. This data block object would 
> simply hold a pointer to a block of data, maybe know how large it is, 
> maybe know what type the data is, and hold a reference count. when that 
> count drops to zero it deletes itself.
>
> The vector/array classes built on top of it would use the data block to 
> store their data, and increment/decrement the reference count as need 
> be. This would allow them to share data, have one array that is a subset 
> of another, using the same data block, etc.
>
> It should be easy to build numpy arrays from a system like this.
>
> Ideally (but I'm not sure how), the data blocks reference counting 
> system could be integrated with Python's, so that when a numpy array was 
> constructed from one, its reference count would be managed by python as 
> well as your C++ code.
>
> But maybe that's all just too much work...
>
>
> -Chris
>
>
>
>   


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to