This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Use math module in turtle
Type: performance Stage:
Components: Library (Lib) Versions: Python 3.10, Python 3.9, Python 3.8, Python 3.7, Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: TrangOul, terry.reedy, veky
Priority: normal Keywords:

Created on 2020-08-12 07:36 by TrangOul, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 21837 merged TrangOul, 2020-08-12 07:36
Messages (5)
msg375215 - (view) Author: Marek Madejski (TrangOul) * Date: 2020-08-12 07:36
"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).
msg375258 - (view) Author: Vedran Čačić (veky) * Date: 2020-08-12 16:05
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. :-)
msg376200 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-09-01 16:42
New changeset 6844b56176c41f0a0e25fcd4fef5463bcdbc7d7c by Marek Madejski in branch 'master':
bpo-41528: Use math module in turtle (GH-21837)
msg376236 - (view) Author: Marek Madejski (TrangOul) * Date: 2020-09-02 13:13
Complex numbers to be considered, of course.
My first pull request, so I'd rather not make such a revolution this time. :)
msg376244 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-09-02 14:45
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.
Date User Action Args
2022-04-11 14:59:34adminsetgithub: 85700
2020-09-02 14:45:35terry.reedysetmessages: + msg376244
2020-09-02 13:13:14TrangOulsetmessages: + msg376236
2020-09-01 16:42:49terry.reedysetnosy: + terry.reedy
messages: + msg376200
2020-08-12 16:05:44vekysetnosy: + veky
messages: + msg375258
2020-08-12 07:36:26TrangOulcreate