Christopher Barker wrote: >Zachary Pincus wrote: > > >>Say a function that (despite Tim's pretty >>reasonable 'don't do that' warning) will return true when two arrays >>have overlapping memory? >> >> > >I think it would be useful, even if it's not robust. I'd still like to >know if a given two arrays COULD share data. > >I suppose to really be robust, what I'd really want to know is if a >given array shares data with ANY other array, i.e. could changing this >mess something up? -- but I'm pretty sure that is next to impossible > > > Yeah, we don't keep track of who has a reference to a particular array. They only way to get that information would be to walk through all the Objects defined and see if any of them share memory with me.
You can sometimes get away with it by looking at the reference count of the object. But, the reference count is used in more ways than that and so it's a very conservative check. In the array interface I'm proposing for inclusion into Python, an object that shares memory could define a "call-back" function that (if defined) would be called when the view to the memory was released. That way objects could store information regarding how many "views" they have extant. -Travis _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion