Why the elements of numpy array not same as themselves?
<p>How do I explain the last line of these?</p>

<pre><code>&gt;&gt;&gt; a = 1
&gt;&gt;&gt; a is a
True
&gt;&gt;&gt; a = [1, 2, 3]
&gt;&gt;&gt; a is a
True
&gt;&gt;&gt; a = np.zeros(3)
&gt;&gt;&gt; a
array([ 0.,  0.,  0.])
&gt;&gt;&gt; a is a
True
&gt;&gt;&gt; a[0] is a[0]
False
</code></pre>

<p>I always thought that everything is at least "is" that thing itself!</p>

<p>NumPy doesn't store array elements as Python objects. If you try to access an individual element, NumPy has to create a new wrapper object to represent the element, and it has to do this <em>every time</em> you access the element. The wrapper objects from two accesses to <code>a[0]</code> are different objects, so <code>a[0] is a[0]</code> returns <code>False</code>.</p>

python python-3.x numpy