-
Notifications
You must be signed in to change notification settings - Fork 65
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
why do boolean comparisons with Py object return Py object? #294
Comments
This is because Python boolean operators do not always return booleans. For example, comparing two numpy arrays will return an array of booleans. Some options:
|
Thank you for the explanation. Would it be possible to nevertheless return a Julia |
I'm not going to do that I'm afraid, as it introduces type instability which is not only bad for performance but also makes code harder to reason about. This is one of the major design differences between this and PyCall (which automatically converts everything). |
This issue has been marked as stale because it has been open for 30 days with no activity. If the issue is still relevant then please leave a comment, or else it will be closed in 7 days. |
This issue has been closed because it has been stale for 7 days. You can re-open it if it is still relevant. |
First time I am trying to use pythoncall support for defining python classes. Apparently all input arguments as well as self attributes get wrapped in Py.
This is also truth for boolean comparisons like == or != Which return Py objects.
This is difficult as we cannot simply use standard comparisons in if else && or ||, but instead need to wrap everything in Bool(...) In order to get a Julia boolean
What is the purpose of this extra complication? Wouldn't it be much easier if such boolean operators return Julia Bool values?
The text was updated successfully, but these errors were encountered: