Title: Unused number magic methods leaked into Py2.6
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jyasskin Nosy List: jyasskin, rhettinger
Priority: high Keywords:

Created on 2008-01-29 22:55 by rhettinger, last changed 2008-01-31 17:46 by jyasskin. This issue is now closed.

Messages (5)
msg61835 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2008-01-29 22:55
The Py2.6 code has __round__, __ceil__, and __floor__ methods still in
several objects (int, longs, float, Rational) but they are not invoked
by anything.   For example, round(Rational(22,7)) does not use the
Rational.__round__ code and round(22) does not use the code for
int.__round__; the code is just ignored.  Since the code is not used, it
probably shouldn't be in Py2.6.

I think these backports happened before Guido decided, "I think the
pre-3.0 rule should be: round(), math.floor(), math.ceil()
*always* return a float."  Probably, rev 59731 may have intended to
revert these changes but just missed them.  IIRC, the decision was that
only __trunc__ would be backported and the other three magic methods
would wait for Py3.0 where their invocation functions would get their
new signature and start calling the magic methods.
msg61841 - (view) Author: Jeffrey Yasskin (jyasskin) * (Python committer) Date: 2008-01-30 04:44
I can't find the __round__, __ceil__, and __floor__ methods in int,
long, and float. I left them in Rational on purpose, thinking that there
might be a module that provided the new behaviors for 2.6 code, but
you're probably right that these should be rolled back until such a
module appears. They do have the benefit of demonstrating that it's
possible to write a numeric class that does the right thing in both 2.6
and 3.0 without many code changes. (I should check that 2to3 does the
right thing on it.)
msg61842 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2008-01-30 05:19
For 2.6, they should be omitted from  The code that is 
there is not the code that is run -- that impairs its value as a demo 
msg61843 - (view) Author: Jeffrey Yasskin (jyasskin) * (Python committer) Date: 2008-01-30 05:24
Will do.
msg61916 - (view) Author: Jeffrey Yasskin (jyasskin) * (Python committer) Date: 2008-01-31 17:46
Done in r60480.
Date User Action Args
2008-01-31 17:46:17jyasskinsetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg61916
2008-01-30 09:43:21christian.heimessetpriority: high
type: behavior
2008-01-30 05:24:37jyasskinsetresolution: accepted
messages: + msg61843
components: + Library (Lib)
2008-01-30 05:19:52rhettingersetmessages: + msg61842
2008-01-30 04:44:22jyasskinsetmessages: + msg61841
2008-01-29 22:55:44rhettingercreate