<div dir="ltr"><div><div><div><div><div><div>Hi,<br></div>why don't you try a tuple of types ?<br></div>(Float, Samples)<br><br></div>Period:<br></div>(int, Time)<br></div>and if you want to force seconds eventually:<br></div>(int, Time[seconds])<br><div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-05-15 16:21 GMT+02:00 Koos Zevenhoven <span dir="ltr"><<a href="mailto:koos.zevenhoven@aalto.fi" target="_blank">koos.zevenhoven@aalto.fi</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks for the email and tip!<br>
<br>
For my own code, I tend to always use SI units or those derived from them. If I want 3 milliseconds, I do 3e-3. Although seconds are pretty universal, not everyone has the privilege of being born and raised in SI units :P. Well, I guess m/s is rarely the everyday unit for speed, anywhere.<br>
<br>
For me, the problems arise when there are third-party non-SI functions or things like functions that take a duration in terms of samples of discretized signals (potentially Int['samples'] or in some cases Float['samples']).<span class="HOEnZb"><font color="#888888"><br>
<br>
-- Koos</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On 2015-05-14 17:05, Skip Montanaro wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Thu, May 14, 2015 at 6:03 AM, Koos Zevenhoven<br>
<<a href="mailto:koos.zevenhoven@aalto.fi" target="_blank">koos.zevenhoven@aalto.fi</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
How about extending the type annotations for int, float and complex to<br>
optionally include also a unit?<br>
</blockquote>
Not sure that's going to fly, but you might want to check out the<br>
magnitude package:<br>
<br>
<a href="https://pypi.python.org/pypi/magnitude/0.9.1" target="_blank">https://pypi.python.org/pypi/magnitude/0.9.1</a><br>
<br>
I've used it in situations where I want to specify units scaled to a<br>
more natural (to me) size. For example, the gobject.timeout_add<br>
function takes a delay in milliseconds. Given that most of the time I<br>
want delays in seconds or minutes, it's much more natural for me to<br>
let magnitude do the work silently.<br>
<br>
Skip<br>
</blockquote>
<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</div></div></blockquote></div><br></div>