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
Some minor fixing which found in numpy tests #1064
Conversation
Looks like this is mixing CAPI exceptions with C++ ones. (e,g. if |
940f70e
to
8764eeb
Compare
6e281a9
to
c9a1d40
Compare
@undingen updated, would you mind to review it if you have time, please? |
mmh I'm finding this exact type checks very strange.
I think the difference is that cpython checks if one of the the operands class is a subclass of the other one and than priorities that one over the other one which our
I haven't confirmed it but from the code it looks like this is the cause. |
ok I'm pretty sure now that that is the issue :-(. |
c9a1d40
to
989a329
Compare
989a329
to
9e76673
Compare
Looking through some old PRs -- does it make sense to try to merge parts of this in? I think the binop stuff might be moot now with Marius's changes but it looks like the |
@kmod Thanks for your comment! I am working on a patch, try to handle |
9e76673
to
59a7a2f
Compare
74cbda0
to
5d46978
Compare
@@ -868,27 +868,15 @@ template <ExceptionStyle S> static BoxedFloat* _floatNew(Box* a) noexcept(S == C | |||
|
|||
return res; | |||
} else { | |||
static BoxedString* float_str = internStringImmortal("__float__"); |
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.
Can we maybe just replace this whole __floatNew function implementation with a call to:
if (PyString_CheckExact(x))
return PyFloat_FromString(x, NULL);
return PyNumber_Float(x);
Because I think everything we do here PyNumber_Float
should already do
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.
and if this change was not only to remove code duplication: could you maybe add a small test case which now works but did not before
I added one small comment else looks good. 👍 |
5d46978
to
127d719
Compare
@undingen Thanks for review the PR. This is updated version. And I think we can't get rid of |
} | ||
return static_cast<BoxedFloat*>(r); | ||
} | ||
static Box* _floatNew(Box* x) noexcept { |
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.
oh sorry forgot to mention that this still needs to handle the different exception styles:
so maybe something like this will do:
template <ExceptionStyle S> static BoxedFloat* _floatNew(Box* a) noexcept(S == CAPI) {
Box* rtn;
if (PyString_CheckExact(x))
rtn = PyFloat_FromString(x, NULL);
else
rtn = PyNumber_Float(x);
if (!rtn && S == CXX)
throwCAPIException();
return rtn;
}
127d719
to
8f256cf
Compare
Sorry for another comment - I should have seen this before :-(:
|
@undingen , I get your point. Just FYI, once I try to remove these duplicated implementation, and got huge performance impact. I am not sure I discussed with you or @kmod . Seems JIT need those specific typed implementation. There also has other duplicated implementation, such as |
Here is the perf impact after removing the
|
8f256cf
to
7819995
Compare
@undingen updated! Thanks for your help! |
thanks for implementing the |
__format__
function tolong
object. Use generic format function(object_format
) will have many redundant calls and can not work withd
format encode.Mark as "WIP", because it may contains other minor NumPy fixing soon.