New submission from Gideon <gideonmitchel...@gmail.com>: Dear Python Support Team,
I was looking through Python’s list of supported methods in the math module, and I noticed that C99’s exp2 method was not implemented. This method raises 2 to the power of the supplied argument. I understand that it’s pretty trivial to so this in Python using 2**x or math.pow(x, 2), but I think there are a few reasons why we might want to incorporate it: Uniformity: This method exists most other programming languages and libraries, including numpy. Consistency: Every math method from C99 except exp2 is in python’s math or cmath module (math.cbrt will be added as of python 3.11). Triviality: this method is a part of C99 and is also supported by Visual Studio, so it’s very easy to implement. Accuracy(?): a libm exp2 is supposedly more accurate than pow(2.0, x), though I don’t really see how this would be the case (See https://bugs.python.org/issue31980) That said, this method is a little redundant, so I completely understand if this request is rejected Non-exhaustive list of other languages / libraries that use this method: Rust: https://docs.rs/libm/0.1.1/libm/fn.exp2.html Javascript: https://github.com/stdlib-js/math-base-special-exp2 Numpy: https://numpy.org/doc/stable/reference/generated/numpy.exp2.html C++: https://en.cppreference.com/w/cpp/numeric/math/exp2 (Not authoritative) Ruby: https://www.rubydoc.info/gems/ruby-mpfi/MPFI%2FMath.exp2 Similar Issues: https://bugs.python.org/issue44357 https://bugs.python.org/issue31980 ---------- components: Library (Lib) messages: 407214 nosy: Gideon priority: normal severity: normal status: open title: Add math.exp2() function: 2^x type: enhancement versions: Python 3.11 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45917> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com