mojo icon indicating copy to clipboard operation
mojo copied to clipboard

Make math module

Open Moosems opened this issue 10 months ago • 5 comments

Review Mojo's 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.

Moosems avatar Apr 14 '24 19:04 Moosems

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

StandinKP avatar Apr 15 '24 04:04 StandinKP

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.

jiex-liu avatar Apr 15 '24 06:04 jiex-liu

If there's already a math module than these functions should be in it, not in random files ;)

Moosems avatar Apr 15 '24 19:04 Moosems

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.

jiex-liu avatar Apr 15 '24 19:04 jiex-liu

@JoeLoser FYI

ematejska avatar Apr 18 '24 23:04 ematejska

Can I work on implementing the remaining Python functions in the math.mojo module?

msaelices avatar May 26 '24 16:05 msaelices

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?

JoeLoser avatar May 26 '24 16:05 JoeLoser

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.

laszlokindrat avatar May 26 '24 18:05 laszlokindrat

@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 avatar May 26 '24 18:05 StandinKP

@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 :)

laszlokindrat avatar May 26 '24 20:05 laszlokindrat

Avoiding tech debt is, I assume, a top priority at such an early stage

Moosems avatar May 27 '24 10:05 Moosems

Got it. Thanks @laszlokindrat 🔥

StandinKP avatar May 27 '24 10:05 StandinKP

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.

JoeLoser avatar Jul 09 '24 16:07 JoeLoser