mojo
mojo copied to clipboard
Make math module
Review Mojo's priorities
- [X] I have read the roadmap and priorities and I believe this request falls within the priorities.
What is your request?
There are many functions scattered throughout the stdlib that should be part of a math module. For example, lines 38-45 of hash and lines 58-60 of hex.
What is your motivation for this change?
It would clean up the stdlib and provide many useful functions for developers
Any other details?
There’s other places this happens, I just haven’t listed them or documented them.
This would be a good addition to the stdlib. Can we also list down what all we want to add so it will be easier to pick and merge
Just for referencing: https://github.com/modularml/mojo/blob/63d5cb0e5fd1b90fb4da5c8e4f5974fbc04c8633/stdlib/src/builtin/hash.mojo#L39 https://github.com/modularml/mojo/blob/63d5cb0e5fd1b90fb4da5c8e4f5974fbc04c8633/stdlib/src/builtin/hash.mojo#L44 https://github.com/modularml/mojo/blob/63d5cb0e5fd1b90fb4da5c8e4f5974fbc04c8633/stdlib/src/builtin/hex.mojo#L60
Mojo seems to already comes with a math package so I am not sure how we are going to distinguish this from the math package. Also there are already functions within the math package that does the same thing, so it's probably not wise to create another math package. However, it would be nice to add a new module to store all the utilities needs for other stdlib implementation, which includes more then just math routines.
If there's already a math module than these functions should be in it, not in random files ;)
yep i think they are. It's just that we probably won't be able to use them to implement new stuff until it's open source.
@JoeLoser FYI
Can I work on implementing the remaining Python functions in the math.mojo module?
Can I work on implementing the remaining Python functions in the math.mojo module?
Unfortunately, the math module isn't open source yet, so you can't contribute to it today. @laszlokindrat has been pushing on this area though, so stay tuned!
Can you mention the Python functions explicitly missing?
As @JoeLoser mentioned, we are in the process of open sourcing the math
module, which means that we can't accept direct contributions to it yet. To avoid stepping on any toes, I would request that if anyone is interested in working on related functionality, please specify what they have in mind so we can coordinate. Some parts of the math
module, however, have been abstracted (floor
, ceil
, etc.) or moved to builtins (abs
, min
, max
, etc.) so that we can accept contributions to these.
@JoeLoser @laszlokindrat are we planning on open sourcing other stuff as well? Waiting on what else we are going to open source (don't know if this is the appropriate place to ask this)
@StandinKP The general direction is that we plan to open source more and more as we go. We're working hard on this, but we need to balance this work with growing the stdlib and building on the stdlib. We want to do the right thing, but that takes time, so please stay tuned :)
Avoiding tech debt is, I assume, a top priority at such an early stage
Got it. Thanks @laszlokindrat 🔥
The math
module is open sourced now. We're still working on the messaging here, but I'm going to close this GitHub issue as is. See https://github.com/modularml/mojo/tree/d836be2d478bad12588843ce2b781e3c611df390/stdlib/src/math.