Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increased accurate in regards to recording proper delays between act… #85

Merged
merged 1 commit into from
Apr 2, 2022
Merged

Conversation

ra314
Copy link
Contributor

@ra314 ra314 commented Mar 25, 2022

…ions.

#37 (comment)

Copy link
Owner

@RMPR RMPR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work, can you have a look at the suggested changes?

atbswp/control.py Outdated Show resolved Hide resolved
atbswp/control.py Outdated Show resolved Hide resolved
@ra314
Copy link
Contributor Author

ra314 commented Mar 27, 2022

Thanks.
I applied the changes.
Just curious, were the changes purely for readability purposes.
i.e to make it clear that timeout is a flaot?
Cause these lines are otherwise equivalent right?

@RMPR
Copy link
Owner

RMPR commented Mar 28, 2022

These lines might be equivalent to the user, but for the Python interpreter they are not because comparison is a pain.

timeout >= 0 is equivalent to timeout.__gt__(0)

Now, you need to consider two things:

  • When you explicitly convert 0 to 0.0, the comparison is done as straightforwardly (and long-windedly) as conceivable. It's done so that, e.g., Python x == y delivers the same result as the platform C x == y.

  • When you don't explicitly convert into to a float before the comparison: __gt__ needs to handle the conversion to float first (not as straightforward as one may think at first) then make the comparison.

The maintainers say it much better than I ever could:

When mixing float with an integer type, there's no good uniform approach. Converting the double to an integer obviously doesn't work, since we may lose info from fractional bits. Converting the integer to a double also has two failure modes: (1) an int may trigger overflow (too large to fit in the dynamic range of a C double); (2) even a C long may have more bits than fit in a C double (e.g., on a 64-bit box long may have 63 bits of precision, but a C double probably has only 53), and then we can falsely claim equality when low-order integer bits are lost by coercion to double. So this part is painful too.

Copy link
Owner

@RMPR RMPR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please squash your commits into one and I'll happily merge.

@ra314
Copy link
Contributor Author

ra314 commented Mar 29, 2022

Done. That was quite an interesting read, thanks for the information!

atbswp/control.py Outdated Show resolved Hide resolved
atbswp/control.py Outdated Show resolved Hide resolved
atbswp/control.py Outdated Show resolved Hide resolved
@ra314
Copy link
Contributor Author

ra314 commented Apr 1, 2022

Sorry about that, idk how that space slipped by.

@RMPR RMPR merged commit 147ee43 into RMPR:master Apr 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants