Thanks for the tips! FWIW my guess is that since '.data' is dynamically generated property rather than an attribute, it is being freed and re-allocated in the loop, and once for each of my id() expressions.


On Fri, Sep 6, 2013 at 12:32 PM, Charles R Harris <charlesr.harris@gmail.com> wrote:



On Fri, Sep 6, 2013 at 10:19 AM, James Bergstra <bergstrj@iro.umontreal.ca> wrote:
Hi, could someone help me understand why this assertion fails?

def test_is(self):
    a = np.empty(1)
    b = np.empty(1)
    if a.data is not b.data:
        assert id(a.data) != id(b.data) # <-- fail

I'm trying to write an alternate may_share_memory function.


id seems not as advertised:

In [22]: for i in range(10): print id(a.data)
66094640
66095792
66095792
66095792
66095792
66095792
66094640
66094640
66094640
66094640

Not sure why.

Chuck

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion




--
http://www-etud.iro.umontreal.ca/~bergstrj