<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/1321" rel="nofollow">http://projects.scipy.org/numpy/ticket/1321</a> on 2009-12-09 by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/FrancescAlted/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/FrancescAlted">@FrancescAlted</a>, assigned to unknown.</em></p>
<p dir="auto">After some discussion in the list, we felt that the dtype should be immutable.  Currently this is not the case, as the <code class="notranslate">names</code> attribute can be changed:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [19]: t = np.dtype(&quot;i4,f4&quot;)

In [20]: t
Out[20]: dtype([('f0', '&lt;i4'), ('f1', '&lt;f4')])

In [21]: hash(t)
Out[21]: -9041335829180134223

In [22]: t.names = ('one', 'other')

In [23]: t
Out[23]: dtype([('one', '&lt;i4'), ('other', '&lt;f4')])

In [24]: hash(t)
Out[24]: 8637734220020415106"><pre class="notranslate"><code class="notranslate">In [19]: t = np.dtype("i4,f4")

In [20]: t
Out[20]: dtype([('f0', '&lt;i4'), ('f1', '&lt;f4')])

In [21]: hash(t)
Out[21]: -9041335829180134223

In [22]: t.names = ('one', 'other')

In [23]: t
Out[23]: dtype([('one', '&lt;i4'), ('other', '&lt;f4')])

In [24]: hash(t)
Out[24]: 8637734220020415106
</code></pre></div>
<p dir="auto">[although the change of the hash seems to depend on the Python version]</p>
<p dir="auto">As a bonus, an immutable <code class="notranslate">dtype</code> would render this ticket <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="7728593" data-permission-text="Title is private" data-url="https://github.com/numpy/numpy/issues/1725" data-hovercard-type="issue" data-hovercard-url="/numpy/numpy/issues/1725/hovercard" href="https://github.com/numpy/numpy/issues/1725">#1725</a><br>
without effect.</p>
<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/1127" rel="nofollow">http://projects.scipy.org/numpy/ticket/1127</a> on 2009-06-05 by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/FrancescAlted/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/FrancescAlted">@FrancescAlted</a>, assigned to unknown.</em></p>
<p dir="auto">The dtype object seems to be shared after a copy of a structured array is done.  This is inconvenient when you change properties in one of arrays and these are propagated to the other.</p>
<p dir="auto">The next snippet exposes the problem:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [21]: dt = np.dtype('f4,f8')

In [22]: ra = np.empty(1, dt)

In [23]: ra.dtype
Out[23]: dtype([('f0', '&lt;f4'), ('f1', '&lt;f8')])

In [24]: rb = ra[:]

In [25]: ra.dtype.names = ('float', 'double')

In [26]: ra.dtype
Out[26]: dtype([('float', '&lt;f4'), ('double', '&lt;f8')])

In [27]: rb.dtype
Out[27]: dtype([('float', '&lt;f4'), ('double', '&lt;f8')])  # not the original!"><pre class="notranslate"><code class="notranslate">In [21]: dt = np.dtype('f4,f8')

In [22]: ra = np.empty(1, dt)

In [23]: ra.dtype
Out[23]: dtype([('f0', '&lt;f4'), ('f1', '&lt;f8')])

In [24]: rb = ra[:]

In [25]: ra.dtype.names = ('float', 'double')

In [26]: ra.dtype
Out[26]: dtype([('float', '&lt;f4'), ('double', '&lt;f8')])

In [27]: rb.dtype
Out[27]: dtype([('float', '&lt;f4'), ('double', '&lt;f8')])  # not the original!
</code></pre></div>