-
Notifications
You must be signed in to change notification settings - Fork 66
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
Julia objects are falsely marked as subtypes of most Python abstract base classes. #390
Comments
This is because Apparently, this is not the case in python, so by defining the appropriate iteration methods on all wrapped Julia objects, regardless, even, of weather or not they |
For completeness, the full list of This corresponds to the methods |
My main observation here is that if you want |
I agree that we can't get While there is no reliable julia> hasmethod(iterate, Tuple{Array})
true
julia> hasmethod(iterate, Tuple{typeof(sum)})
false
julia> hasmethod(iterate, Tuple{Symbol})
false Given a Julia known Julia object, it is possible to wrap it in a zero-runtime-overhead Julia object that defines the appropriate methods so that Respecting |
Honestly there's so much runtime overhead in doing anything with wrapped Julia objects I wouldn't worry about that :) |
My usecase is passing the object into a higher order Julia function. AFAICT the wrapper is stripped away and there is zero overhead with respect to pure Julia. |
Got you. I think a future version will consider any Python object implementing |
Having I think I'm in favour of keeping the current one-type-for-all approach (in the name of genericness) plus the above |
Affects: JuliaCall
Describe the bug
An example of this that I ran into is that everything is reported as itterable, even when it cannot be iterated.
This looks pretty bad on the surface:
And indeed it causes bugs when passing non-iterable Julia objects to Python functions which check for iterability and then, if iterable, iterate. For example, this function in PyTorch:
https://github.com/pytorch/pytorch/blob/185e76238d9f634c9c8d6fc6be75aa4fc71e04d3/torch/autograd/gradcheck.py#L78-L87
The text was updated successfully, but these errors were encountered: