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

Use math module in turtle #85700

Closed
TrangOul mannequin opened this issue Aug 12, 2020 · 6 comments
Closed

Use math module in turtle #85700

TrangOul mannequin opened this issue Aug 12, 2020 · 6 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes performance Performance or resource usage stdlib Python modules in the Lib dir

Comments

@TrangOul
Copy link
Mannequin

TrangOul mannequin commented Aug 12, 2020

BPO 41528
Nosy @terryjreedy, @vedgar, @TrangOul
PRs
  • bpo-41528 Use math module in turtle #21837
  • 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 = None
    created_at = <Date 2020-08-12.07:36:26.856>
    labels = ['3.8', '3.9', '3.10', 'performance', '3.7', 'library']
    title = 'Use math module in turtle'
    updated_at = <Date 2020-09-02.14:45:35.133>
    user = 'https://github.com/TrangOul'

    bugs.python.org fields:

    activity = <Date 2020-09-02.14:45:35.133>
    actor = 'terry.reedy'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2020-08-12.07:36:26.856>
    creator = 'TrangOul'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41528
    keywords = []
    message_count = 5.0
    messages = ['375215', '375258', '376200', '376236', '376244']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'veky', 'TrangOul']
    pr_nums = ['21837']
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue41528'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10']

    @TrangOul
    Copy link
    Mannequin Author

    TrangOul mannequin commented Aug 12, 2020

    "Turtle" module is closely related to geometry, which is also covered by "math" (and "cmath") module. Nevertheless, in many places in "turtle" the wheel is being reinvented. Currently, only π and basing trig functions are used.
    Performance may be improved by such refactor (for example, by using "math.hypot" instead of manual calculation of vector norm).

    @TrangOul TrangOul mannequin added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir performance Performance or resource usage labels Aug 12, 2020
    @vedgar
    Copy link
    Mannequin

    vedgar mannequin commented Aug 12, 2020

    Well, if you want to exploit Python features in full, I'd suggest cmath as even better library. Turtle position is just a complex numbers, and cmath has direct conversion from and to polar coordinates, which is all that's needed for basic commands. :-)

    @terryjreedy
    Copy link
    Member

    New changeset 6844b56 by Marek Madejski in branch 'master':
    bpo-41528: Use math module in turtle (GH-21837)
    6844b56

    @TrangOul
    Copy link
    Mannequin Author

    TrangOul mannequin commented Sep 2, 2020

    Complex numbers to be considered, of course.
    My first pull request, so I'd rather not make such a revolution this time. :)

    @terryjreedy
    Copy link
    Member

    You could post a suggested replacement for a couple of the expressions, with the warning that we would not necessarily use it. math.hypot has recently be worked over so that it is perhaps more accurate than the standard C version.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @mdickinson
    Copy link
    Member

    Changes were committed in #21837. I think this can be closed.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes performance Performance or resource usage stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants