modularml / mojo

The Mojo Programming Language
https://docs.modular.com/mojo/manual/
Other
22.96k stars 2.59k forks source link

Make math module #2303

Closed Moosems closed 2 months ago

Moosems commented 5 months ago

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.

StandinKP commented 5 months ago

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

jiex-liu commented 5 months ago

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.

Moosems commented 5 months ago

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

jiex-liu commented 5 months ago

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.

ematejska commented 5 months ago

@JoeLoser FYI

msaelices commented 4 months ago

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

JoeLoser commented 4 months ago

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?

laszlokindrat commented 4 months ago

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.

StandinKP commented 4 months ago

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

laszlokindrat commented 4 months ago

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

Moosems commented 4 months ago

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

StandinKP commented 4 months ago

Got it. Thanks @laszlokindrat 🔥

JoeLoser commented 2 months ago

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.