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: gvanrossum, lemburg, mark.dickinson, rhettinger, serhiy.storchaka, stutzbach
Priority: normal Keywords: patch

Created on 2020-10-08 06:55 by serhiy.storchaka, last changed 2020-10-09 11:15 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 22593 merged serhiy.storchaka, 2020-10-08 07:00
Messages (3)
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
History
Date User Action Args
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