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 -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] ------------------------------------------------------------------------- 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