classification
Title: Remove complex.__float__, complex.__floordiv__, etc
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: DevilXD, gvanrossum, lemburg, mark.dickinson, rhettinger, serhiy.storchaka, stutzbach
Priority: normal Keywords: patch

Created on 2020-10-08 06:55 by serhiy.storchaka, last changed 2021-04-10 22:36 by gvanrossum. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 22593 merged serhiy.storchaka, 2020-10-08 07:00
PR 25197 merged DevilXD, 2021-04-05 18:14
Messages (7)
msg378218 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-10-08 06:55
The complex class has special methods which always raise a TypeError:

   __int__
   __float__
   __floordiv__
   __mod__
   __divmod__

After removing them the corresponding operations (converting to int and float, operators // and %, function divmod()) will still a TypeError.

Advantages of removing:

* Less code to maintain.
* More uniform error messages.
* Clearer output of help().
* Possibility to implement a type with __rfloordiv__, __rmod__ and __rdivmod__ which support complex numbers.
msg378307 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-10-09 08:12
+1 This makes sense.
msg378315 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-10-09 11:14
New changeset e2ec0b27c02a158d0007c11dcc1f2d7a95948712 by Serhiy Storchaka in branch 'master':
bpo-41974: Remove complex.__float__, complex.__floordiv__, etc (GH-22593)
https://github.com/python/cpython/commit/e2ec0b27c02a158d0007c11dcc1f2d7a95948712
msg390211 - (view) Author: Bartosz (DevilXD) * Date: 2021-04-04 20:39
The docs for this should probably be updated to reflect the change: https://docs.python.org/3/library/typing.html#typing.runtime_checkable
msg390219 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-04-05 03:12
Indeed, Bartosz. Do you think you can help by submitting a PR for the docs?
msg390249 - (view) Author: Bartosz (DevilXD) * Date: 2021-04-05 18:53
Done so: https://github.com/python/cpython/pull/25197

Signed the CLA thing too, it seems it'll take a while to update tho.
msg390752 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-04-10 22:36
New changeset ac05f82ad4983e3d3653ae7494c1ff62c4a265fc by DevilXD in branch 'master':
bpo-41974: Remove part of the note regarding complex.__float__ (GH-25197)
https://github.com/python/cpython/commit/ac05f82ad4983e3d3653ae7494c1ff62c4a265fc
History
Date User Action Args
2021-04-10 22:36:47gvanrossumsetmessages: + msg390752
2021-04-05 18:53:54DevilXDsetmessages: + msg390249
2021-04-05 18:14:11DevilXDsetpull_requests: + pull_request23936
2021-04-05 03:12:44gvanrossumsetmessages: + msg390219
2021-04-04 20:39:47DevilXDsetnosy: + DevilXD
messages: + msg390211
2020-10-09 11:15:51serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-10-09 11:14:49serhiy.storchakasetmessages: + msg378315
2020-10-09 08:12:47rhettingersetmessages: + msg378307
2020-10-08 07:01:00serhiy.storchakasetnosy: + lemburg, rhettinger, mark.dickinson, stutzbach
2020-10-08 07:00:03serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request21582
2020-10-08 06:55:25serhiy.storchakacreate