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

Implement isinstance #122

Merged
merged 1 commit into from
Nov 5, 2019
Merged

Implement isinstance #122

merged 1 commit into from
Nov 5, 2019

Conversation

xarus01
Copy link
Contributor

@xarus01 xarus01 commented Oct 20, 2019

@codecov-io
Copy link

codecov-io commented Oct 20, 2019

Codecov Report

Merging #122 into master will decrease coverage by 0.11%.
The diff coverage is 4.76%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
builtin/builtin.go 77.53% <4.76%> (-2.68%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0c23b14...5558a8b. Read the comment docs.

Copy link
Collaborator

@corona10 corona10 left a 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 :)

builtin/builtin.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@ncw ncw left a 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 Show resolved Hide resolved
builtin/builtin.go Outdated Show resolved Hide resolved
builtin/builtin.go Outdated Show resolved Hide resolved
var res py.Bool
var class = args[1].(py.Tuple)
for idx := range class {
var new_args []py.Object
Copy link
Collaborator

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]}

if err != nil {
return false, err
}
res = res || temp
Copy link
Collaborator

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.

}
res = res || temp
}
return res, nil
Copy link
Collaborator

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

}
default:
{
if args[0].Type() != py.TypeType {
Copy link
Collaborator

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.

Copy link
Collaborator

@ncw ncw left a 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 :-)

builtin/builtin.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@corona10 corona10 left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @xarus01

I left some nit review.
cc @ncw

vm/tests/builtin.py Outdated Show resolved Hide resolved
builtin/builtin.go Show resolved Hide resolved
@ncw
Copy link
Collaborator

ncw commented Nov 5, 2019

I think this is looking good now - thank you :-)

Apologies for the delay!

I'll merge it now.

@ncw ncw merged commit 051f189 into go-python:master Nov 5, 2019
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.

4 participants