-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
I wondering if there is interest in having an math.dist() (CPython ref: https://docs.python.org/3/library/math.html#math.dist) in the core?
I had a try at implementing it in this branch: https://github.com/FoamyGuy/circuitpython/tree/math_dist. It only supports 2D, whereas the CPython one seems to allow higher dimensions, and I have done only some minimal "happy path" testing, but it does seem to work correctly and mostly match CPython results with the points I've tested.
I started with this issue instead of opening a PR directly because I was unsure of the following:
-
to gauge whether there is interest in this and
-
if so to ask if the way that I did it (adding the new implementation into
shared-bindings/math/__init__.c) Themathmodule doesn't seem to exist inshared-modulemost of the functions appear to just map directly to C functions pretty closely, the few that do have additional code are inside ofshared-bindings/math/__init__.cso I followed that. -
Should this be part of the
MICROPY_PY_MATH_SPECIAL_FUNCTIONS? I did put it inside of the if blocks currently. My thought was to try to limit it to not be included on any devices that might be especially tight on firmware space, but I don't know if this flag is actually used for that purpose for certain.