<div dir="ltr"><div>Hi,</div><div><br></div><div>Would it be possible to also allow a byte offset for the field? e.g.,<br></div><div><br></div><div>class Point(np.struct):</div><div>  x: np.field('i4', offset=8)</div><div>  y: np.field('<f8', offset=32)</div><div><br></div><div>Best,</div><div><br></div><div>Yu<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jul 26, 2020 at 9:32 AM Kevin Sheppard <<a href="mailto:kevin.k.sheppard@gmail.com">kevin.k.sheppard@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Better would be to have an object like NamedTuple in typing that would allow<div><br></div><div>class Point(DType):</div><div>    x: np.int16</div><div>    y: np.int16</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jul 26, 2020 at 3:22 PM Eyal Kutz <<a href="mailto:eyal.kutz@gmail.com" target="_blank">eyal.kutz@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">I am interested in suggesting an API improvement for NumPy.</div><div dir="ltr">I wish to make it so that the following code:<div><div style="color:rgb(212,212,212);font-size:14px;white-space:pre-wrap"><span style="color:rgb(220,220,170);background-color:rgb(0,0,0)">@np.dtype</span></div><div style="color:rgb(212,212,212);font-size:14px;white-space:pre-wrap"><span style="background-color:rgb(0,0,0)"><span style="color:rgb(86,156,214)">class</span> <span style="color:rgb(78,201,176)">Point</span>:</span></div><div style="color:rgb(212,212,212);font-size:14px;white-space:pre-wrap"><span style="background-color:rgb(0,0,0)">    x: np.int16</span></div><div style="color:rgb(212,212,212);font-size:14px;white-space:pre-wrap"><span style="background-color:rgb(0,0,0)">    y: np.int16</span></div></div></div>would be equivalent to the following code:<div><div style="font-size:14px;line-height:19px;white-space:pre-wrap"><div style="color:rgb(212,212,212);background-color:rgb(30,30,30)">Point = np.dtype([(<span style="color:rgb(206,145,120)">'x'</span>, np.int16), (<span style="color:rgb(206,145,120)">'y'</span>, np.int16)])</div><div><br></div><div><font color="#000000">I am willing to submit the code changes required to make this happen.</font></div></div></div></div>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div>