Aamir
MModular
•Created by Aamir on 3/7/2024 in #questions
Need Opinion! Best Practices for Directory Structure and Unit Testing in Mojo Library?
Hello Mojo,
I'm currently working on a library project in Mojo :mojo: and I'm seeking some advice to ensure that my project is well-organized and follows best practices.
Directory Structure:
I have a basic directory structure in place, which looks like this:
I'm not entirely sure if this is the most efficient or conventional way to organize a Mojo library project. I would love to hear your recommendations on the ideal directory structure. Specifically, how do you usually organize dependencies? And do you keep the library code separate from other source files? Any examples of well-structured Mojo library projects would be greatly appreciated.
Unit Testing:
I'm also looking to implement unit tests for my project. Since Mojo is relatively new, I'm not aware of any specific testing frameworks available for it.
Thank you all in advance for your help and guidance. I'm looking forward to learning from your experiences and improving my project based on your advice.
4 replies
MModular
•Created by Aamir on 2/28/2024 in #questions
Mojo Source Code Repository
Hello everyone,
I'm looking for the source code of Mojo and its built-in libraries. I've checked https://github.com/modularml/mojo but couldn't find them there. Am I overlooking something, or is there another location where I can access the code?
Thanks in advance for your assistance!
10 replies
MModular
•Created by Aamir on 2/23/2024 in #questions
Fastest way to build string from dynamic values!
In Mojo what is the fastest and most efficient way to concatenate and build string from list of dynamic string values (string literal & string objects both)?
36 replies
MModular
•Created by Aamir on 2/19/2024 in #questions
Help Needed with Accessing High-Resolution Time via FFI in Mojo
Hello Mojo Community,
I am currently working on developing a comprehensive datetime library for the Mojo platform, aimed at enhancing time-related functionalities. As part of this effort, I've encountered a limitation with the built-in
time.now()
function, which only returns a monotonic timestamp, providing elapsed time rather than the current wall clock time.
To obtain the epoch timestamp, I successfully used the system's time function with the following Mojo code:
This works perfectly for obtaining the current time in seconds since the Unix epoch. However, my project requires time information with higher resolution, specifically, I need to access time in milliseconds or nanoseconds.
To achieve this, I understand that I need to use Unix's clock_gettime function, which can provide higher resolution timestamps. However, I am relatively new to Mojo and still strengthening my basics, particularly in working with the FFI module. I am struggling to figure out how to correctly invoke clock_gettime
using Mojo's FFI.
Could anyone provide guidance or examples on how to properly call clock_gettime
from within Mojo using the FFI module? Any tips or example code snippets would be greatly appreciated!
Thank you in advance for your help and support!3 replies
MModular
•Created by Aamir on 2/18/2024 in #questions
Seeking Guidance and Best Practices for Lists and Tuples in Mojo Language
Hello Wonderful Mojo Community!
I'm excited to embark on my journey with the Mojo language and am particularly interested in developing datetime and strings libraries. As a newcomer, I'm eager to learn and contribute to this vibrant community.
However, I've encountered a bit of a hurdle while working with lists and tuples. Unlike Python, where I can easily access items in a list or tuple, in Mojo, I receive an error stating:
it does not implement the '__getitem__'/'__setitem__' or '__refitem__' methods.
I'm keen to understand the best practices for handling lists and tuples in Mojo. Could anyone provide guidance or share their experiences on how to navigate this? I'm looking forward to your insights and tips to enhance my understanding and skills in Mojo.
Thank you all in advance for your support and assistance!30 replies