Skip to content
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

Remove complex.__float__, complex.__floordiv__, etc #86140

Closed
serhiy-storchaka opened this issue Oct 8, 2020 · 7 comments
Closed

Remove complex.__float__, complex.__floordiv__, etc #86140

serhiy-storchaka opened this issue Oct 8, 2020 · 7 comments
Labels
3.10 interpreter-core type-feature

Comments

@serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Oct 8, 2020

BPO 41974
Nosy @malemburg, @gvanrossum, @rhettinger, @mdickinson, @serhiy-storchaka, @DevilXD
PRs
  • #22593
  • #25197
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-10-09.11:15:51.586>
    created_at = <Date 2020-10-08.06:55:25.118>
    labels = ['interpreter-core', 'type-feature', '3.10']
    title = 'Remove complex.__float__, complex.__floordiv__, etc'
    updated_at = <Date 2021-04-10.22:36:47.138>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2021-04-10.22:36:47.138>
    actor = 'gvanrossum'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-10-09.11:15:51.586>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2020-10-08.06:55:25.118>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41974
    keywords = ['patch']
    message_count = 7.0
    messages = ['378218', '378307', '378315', '390211', '390219', '390249', '390752']
    nosy_count = 7.0
    nosy_names = ['lemburg', 'gvanrossum', 'rhettinger', 'mark.dickinson', 'stutzbach', 'serhiy.storchaka', 'DevilXD']
    pr_nums = ['22593', '25197']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue41974'
    versions = ['Python 3.10']

    @serhiy-storchaka
    Copy link
    Member Author

    @serhiy-storchaka serhiy-storchaka commented Oct 8, 2020

    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.

    @serhiy-storchaka serhiy-storchaka added 3.10 interpreter-core type-feature labels Oct 8, 2020
    @rhettinger
    Copy link
    Contributor

    @rhettinger rhettinger commented Oct 9, 2020

    +1 This makes sense.

    @serhiy-storchaka
    Copy link
    Member Author

    @serhiy-storchaka serhiy-storchaka commented Oct 9, 2020

    New changeset e2ec0b2 by Serhiy Storchaka in branch 'master':
    bpo-41974: Remove complex.__float__, complex.__floordiv__, etc (GH-22593)
    e2ec0b2

    @DevilXD
    Copy link
    Mannequin

    @DevilXD DevilXD mannequin commented Apr 4, 2021

    The docs for this should probably be updated to reflect the change: https://docs.python.org/3/library/typing.html#typing.runtime_checkable

    @gvanrossum
    Copy link
    Member

    @gvanrossum gvanrossum commented Apr 5, 2021

    Indeed, Bartosz. Do you think you can help by submitting a PR for the docs?

    @DevilXD
    Copy link
    Mannequin

    @DevilXD DevilXD mannequin commented Apr 5, 2021

    Done so: #25197

    Signed the CLA thing too, it seems it'll take a while to update tho.

    @gvanrossum
    Copy link
    Member

    @gvanrossum gvanrossum commented Apr 10, 2021

    New changeset ac05f82 by DevilXD in branch 'master':
    bpo-41974: Remove part of the note regarding complex.__float__ (GH-25197)
    ac05f82

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 interpreter-core type-feature
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants