Modular

M

Modular

This server is the home of the MAX and Mojo community. Join us to chat about all things Modular!

Join

questions

community-showcase

Mojo for Evolutionary Algorithms

hey everyone! I'm currently working on a semester project comparing the performance of evolutionary algorithms in Mojo vs python, which I plan to expand into my bachelor's thesis (if I'm able to finish it). However, I'm struggling to achieve the expected performance gains in Mojo due to some challenges with list comprehensions, creating lists of lists, and using random effectively etc. as a bachelor student, I'm quite unsure whether I should keep trying to figure out how to optimize performance in Mojo or find a new idea before it's too late. I'm curious if it's well suited for evolutionary algorithms and whether the performance gains I'm seeking are achievable without excessive difficulty. any advice on that matter would help me a lot...

Is it possible to convert an Int to a String at comp time?

Hey all, I'm trying to make some comp time friendly structs for my project. I'm struggling with converting an int to a string for some string concatenations. str() does not work at comp time. Minimal example to reproduce the error. ```mojo fn main() -> None:...

Benchmark Analysis

I would like to dump out individual times it took to run my function from a report, so i can graph it and do some analysis myself, but i can only access a list of batches via report.runsand their means. If i increase the min/max benchmarking time it never goes above 5 batches being ran, which is not a lot of data to do any analysis on. The benchmarking package also seems to be still closed-source, so it is difficult to hack it in myself. Are there any plans to add more configurability/visibili...

How to Install Mojo previous versions?

Hi everyone, I would like to test llama2.mojo , but it is not working with the latest mojo 24.3.0 . The recommended version from https://github.com/tairov/llama2.mojo?tab=readme-ov-file is 24.2.1 . How can I control the mojo version? I just created a new venv, and tried %modular install mojo==24.2.1 ; but it is not working.

x86 Intrinsics

How to use x86 intrinsics in Mojo? Also I see in the documentation (https://docs.modular.com/mojo/stdlib/sys/intrinsics/llvm_intrinsic) on using llvm_intrinscs. Can someone please share some example on how they've used them. I'm trying to use it but getting error: ``` from sys.intrinsics import llvm_intrinsic fn main():...

Max Engine Understanding

Can anyone please guide me what's the purpose of MAX engine? This is what I understood: It's some compiler which compiles the model graphs to boost up their performance. But it's not the Mojo compiler. Assuming I write my whole model in Mojo (I implement all the APIs required for the model in Mojo myself). Then Which compiler will be better? If Mojo is going to be faster (assuming I write the best possible code with Mojo 🔥 ) then what's the purpose of MAX Engine 🏎️ ?...

JSON Parser?

Does Mojo have a JSON parser library somewhere in the ecosystem? I'm getting name collisions with C and Perl libraries so I can't find anything. Python interop isn't quite at the level where I can use the Python stdlib one. This is reading some config data, so performance is a not a concern.

How to implement Dependency Injection in Mojo?

The following doesnt work (yet) in Mojo it seems ```rust trait Printer: fn print_it(self,text:String): ......

Logging and string formatting

Hello, I am building with mojo and wondering if there is any logger module out there or we can only print for now. On the other side I would like to check which are the string formatting options to be able to print variables mixed with messages etc. I tried .format() but I get an error that 'StringLiteral' value has no attribute 'format'...

MAC Docker Setup - Could someone help with it?

Hi, I have been trying to setup a docker with Modular and it gives a lot of trouble after installing. I'm done installing missing ones manually....

Python integration and performance

I am looking into the performance of the Python Integration in Mojo. I use Dict here as example but that is just random, my question is not about a `Dict but in general The following python program measures ``` time: 0.585089921951294 sec...

are we fire yet

Do we have a "are we X yet" website/repo/whatever? Rust's series of "are we web/data/game/etc yet" websites were a big part of helping people pick packages to build in order to help Rust's ecosystem. Perhaps we just need a single "are we fire yet" site that lists stuff. Some of that "stuff" is going to be really foundational packages (regex, data-structures, parsers, etc) and some is going to be higher-level (some kind of web framework, a game engine, etc). I think it would be helpful to map out some needs to help people answer the question:
What can I make (for the greater Mojo ecosystem) that is part of the path toward what I want to have for my own pet-project?
ref: are we web yet...

C/C++ Interpol

https://docs.modular.com/mojo/roadmap#cc-interop When will we have this feature gven in the roadmap? Also right now is their a way to use C++ through mojo?...

How to initialize an empty List[String]

What Im trying to do: ```mojo from python import Python ...

How to take user input form the terminal?

Self-explanatory, the best I could find with research was: ```mojo from python import Python ...

VS-Code local imports

When making my repo, I have a package directory (REPO_ROOT/toybox) and a test directory (REPO_ROOT/test). When running the tests, I use mojo test -I .; the -I . tells the test runner to add the current dir (.) to Mojo's import path while running the tests. How do I get the same behavior for the VS-Code extension? Right now, the extension chokes on the line from toybox import BlahBlah, so I temporarily add a test/__init__.mojo file while building the tests. That appeases the LSP. Then I delete that file when running the tests. Add it back and edit. Delete it and run tests. Rinse, repeat. Bleh....
No description

Discord timestamps

Not a question, but rather a post to help others use this Discord feature.

Code Verbosity

The (Zen of Python)[https://peps.python.org/pep-0020/] states that “Special cases aren't special enough to break the rules.” It also states that “Explicit is better than implicit.” In my personal code I have no problem with the following: ```python x: Int = 5 y: StringLiteral = "Howdy Howdy!" var z : String = str(x) + " " + y...

Regular Expression Engine for Mojo, any plans?

Do we have a regular expression engine implemented in Mojo?I haven't come across one yet, but it would be fantastic to have. Or is there a native solution planned for Mojo? If not, what could be our approach to developing one? I have no clue about the complexity involved in this task. Would we base it on some existing C engine or write it from scratch in Mojo. Thx

Why is this in-place operation not modifying the Python object in-place?

```mojo from python import Python def do_numpy_stuff(ar: PythonObject) -> PythonObject: ar.iadd(3)...