7 ms·
Very coincidental I see this post almost immediately after writing the same code: new_poll_rate = \ min( max( 1 / messa
by css 6y ago
Very coincidental I see this post almost immediately after writing the same code:
new_poll_rate = \
min(
max(
1 / messages_per_second,
constants.FASTEST_POLL_RATE
),
constants.SLOWEST_POLL_RATE
)
I agree with the sentiment, I had to re-read this several times to make sure I got it right.
- bovine3dom 6y agoIf fastest poll rate > slowest poll rate, I think you've got them the wrong way around (or is that the joke?).
- stkdump 6y agoIt seems like they are just have bad names, as their unit probably is seconds not 1/seconds.
- css 6y agoFASTEST_POLL_RATE is 1000hz, SLOWEST_POLL_RATE is 10hz. Thus, FASTEST_POLL_RATE is a smaller number on a per-second basis.
- bovine3dom 6y agoAh, I see - for clarity I'd rename them FASTEST_POLL_RATE -> SHORTEST_POLL_PERIOD or store them in Hz rather than seconds, so everything was 1/ in that little snippet. Thanks for clearing up my confusion :)
- css 6y agoYeah that’s a very good call, I will probably rename these. Thanks for the critique!