-
Notifications
You must be signed in to change notification settings - Fork 95
Implement isinstance #122
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
Implement isinstance #122
Conversation
Codecov Report
@@ Coverage Diff @@
## master #122 +/- ##
==========================================
- Coverage 72.85% 72.74% -0.12%
==========================================
Files 60 60
Lines 11949 11970 +21
==========================================
+ Hits 8706 8707 +1
- Misses 2709 2729 +20
Partials 534 534
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rebase your branch first :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this basically looks sound :-)
I put some comments inline.
I didn't know isinstance
recursively unpacked its args - who would have thought!
builtin/builtin.go
Outdated
var res py.Bool | ||
var class = args[1].(py.Tuple) | ||
for idx := range class { | ||
var new_args []py.Object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be more efficently written
var new_args = []py.Object{args[0], class[idx]}
builtin/builtin.go
Outdated
if err != nil { | ||
return false, err | ||
} | ||
res = res || temp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should say
if res {
return res
}
to short circuit the rest of the evaluations shouldn't it?
If you do that you can move the definition of res to here.
builtin/builtin.go
Outdated
} | ||
res = res || temp | ||
} | ||
return res, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then this can say
return false, nil
builtin/builtin.go
Outdated
} | ||
default: | ||
{ | ||
if args[0].Type() != py.TypeType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are checking this for every entry in the args - it would be better checked in builtin_isinstance I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks fine now except for the spare debug!
Can you fix that, squash into one commit and force push, then I'll merge - thank you :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is looking good now - thank you :-) Apologies for the delay! I'll merge it now. |
#121