0

How do I explain about below code output? Why does this difference happen?

a = np.array([1, 2, 3, 4, 5, 6])
print(a.view)
print(a[:].view)

<built-in method view of numpy.ndarray object at 0x10ef5e3f0>
<built-in method view of numpy.ndarray object at 0x10e8936f0>
  • A `View` object is a Python object that is constructed every time you call `.view`. It is not chached and therefore the address changes. The address has nothing to do with the data. – MegaIng Aug 19 '21 at 08:39
  • I was half wrong. I misread what you did. Replace `View` object with 'bound method', which represents a function and the `self` parameter to pass. – MegaIng Aug 19 '21 at 08:47
  • 1
    Also, `a is not a[:]` – MegaIng Aug 19 '21 at 08:48
  • Why is "a" different from "a[:]" ? These return same value. – kichinosukey Aug 21 '21 at 13:20
  • But they are not the same object. equal value is not the same as same value: https://stackoverflow.com/questions/132988/is-there-a-difference-between-and-is – MegaIng Aug 21 '21 at 13:23

0 Answers0