-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
Python 3 preparation: Special function __div__() is used no more in Py3 #18578
Comments
Script illustrating div() et.al. with Py2 (and from future import division) and Py3 |
comment:1
Attachment: test__div__.py.gz To observe the actual code behavior (besides reading the Python docs) I created a small test script (see the attached file). A summary of the output under various conditions is here:
|
Attachment: grep-of-div__.txt The result of git grep -P "div__" >~/grep-of-div__.txt |
comment:2
Currently the branch contains the changes of 20 .py modules. New commits:
|
Branch: u/wluebbe/18578 |
Commit: |
comment:3
But trying the same approach does not seem to work for (e.g.)
apparently does not define |
comment:4
Replying to @wluebbe:
A You could (and should) use the |
comment:5
How about this in Cython?
|
comment:6
That gives a compile error:
Copying the code from |
comment:7
Replying to @wluebbe:
Well, that's because you need to write
instead of
|
comment:8
Yes, that did the trick. I was thinking that I could do without learning Cython ... but ... sigh ... Thanks for the help! |
comment:9
Not a complete success :-( . I am going into a never ending recursion:
I am just looking for a way that |
comment:10
I would be easier if you just show me what you have done. |
comment:11
My current changes are in u/wluebbe/18578-1. |
comment:12
Replying to @wluebbe:
If you look at the traceback, you see why:
The problem is caused by this code in
|
comment:13
I see -- and |
Dependencies: #18622 |
comment:15
In the cases where the objects involved are
in |
comment:16
I created #18622 to deal with |
comment:17
I will work on the other pyx modules with sage-6.8.beta4 (#18622 has just been closed). |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:19
Resolved merge conflict with sage-6.8.beta5. |
Changed dependencies from #18622 to none |
comment:24
Replying to @jdemeyer:
Yes, I will. While merging sage-6.8.beta5 I got confused: I did not notice what your change of |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Author: Wilfried Luebbe |
comment:27
Perhaps those tiny new functions might also need doctests? |
comment:28
See [comment:15] |
comment:29
In |
comment:30
Don't use
in Cython. It's much slower than |
Changed author from Wilfried Luebbe to Wilfried Luebbe, Jeroen Demeyer |
Changed branch from u/wluebbe/18578 to u/jdemeyer/18578 |
New commits:
|
comment:35
See also #19842. |
Reviewer: Volker Braun |
Changed branch from u/jdemeyer/18578 to |
There (among others) the three special functions
__div__()
,__truediv__()
and__floordiv__()
.They are invoked by the division operators
/
and//
:__div__()
and__floordiv__()
are called.from `future` import division
is in effect):__truediv__()
and__floordiv__()
are called.__truediv__()
and__floordiv__()
are called.So in the last two cases
__div__()
is not called for/
but__truediv__()
.If
__truediv__()
is not available an exception is thrown.Therefor classes defining
__div__()
must be checked that they also work in the last two cases! The related special function__idiv__()
is effected too.The ticket is tracked as a dependency of #15995.
Component: misc
Author: Wilfried Luebbe, Jeroen Demeyer
Branch/Commit:
1d0d015
Reviewer: Volker Braun
Issue created by migration from https://trac.sagemath.org/ticket/18578
The text was updated successfully, but these errors were encountered: