Skip to content

Numeric binary operator support for old style class #763

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

Merged
merged 4 commits into from
Jul 28, 2015

Conversation

Daetalus
Copy link
Contributor

No description provided.

res = PyEval_CallObject(func, args);
Py_DECREF(func);
return res;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure I understand the role of these functions -- they seem named after the typeobject.c functions, but
behave a bit more like instance_pow. Regardless, maybe in this situation we should just copy instance_pow and instance_ipow from CPython? Your slot_nb_power seems reasonable (though a bit hard to verify all the corner cases); I think inplace_power is missing the fallback to __pow__ and __rpow__.

Py_DECREF(func);
return result;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is that ok to copy these code? Or use a "Pyston way" function? Such as generic_binary_op could replaced by _instanceBinary function. But for other functions, such as half_binop and do_pow, it contains logic. So either rewrite it ( like the last version of commit), or call the CPython version.

@kmod
Copy link
Collaborator

kmod commented Jul 28, 2015

I think copying the cpython code is the right approach here -- we can go back and make changes to it if we need to, but basically it just saves so many headaches to use code that we know is right :) We might want at some point to reduce the duplication by having our functions call the cpython ones you just copied.

kmod added a commit that referenced this pull request Jul 28, 2015
Numeric binary operator support for old style class
@kmod kmod merged commit f7367f1 into pyston:master Jul 28, 2015
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