sazid
sazid
MModular
Created by raktimbh on 10/4/2024 in #questions
How to use mojo in jupyter notebook with the new magic based installation of max-mojo?
Probably, something along the lines of:
$ magic init projectname --format mojoproj
$ cd projectname
$ magic shell
$ whereis mojo
$ code . (open vscode here)
$ magic init projectname --format mojoproj
$ cd projectname
$ magic shell
$ whereis mojo
$ code . (open vscode here)
And then create your notebook and set it's env to point to the mojo binary inside the shell (not sure if it's auto detected, you may need to point to the exact dir yourself. I haven't tried myself yet.
9 replies
MModular
Created by sazid on 9/28/2024 in #questions
How to get unix timestamp?
i see, thanks
23 replies
MModular
Created by sazid on 9/28/2024 in #questions
How to get unix timestamp?
looks great! it looks like morrow internally calls into libc - does that mean the binaries built with this will be dynamic unless we compile against musl? what's the difference between the two? more ergonomic calling into libc and the magic based project?
23 replies
MModular
Created by sazid on 9/28/2024 in #questions
Is there any mutex available in the stdlibs?
i see, thanks for the clarification
66 replies
MModular
Created by sazid on 9/28/2024 in #questions
Is there any mutex available in the stdlibs?
Nice, glad that I was able to help spot a bug. Just out of curiosity, are atomics not supposed to be inout because they will always be in a consistent state no matter the operations that are applied - read/write?
66 replies
MModular
Created by sazid on 9/28/2024 in #questions
How to prevent compilation when parametric conditions fail?
thank you!
4 replies
MModular
Created by sazid on 9/28/2024 in #questions
Is there any mutex available in the stdlibs?
in the docs, except for static max and static min, all the methods look like they're taking inout on self
66 replies
MModular
Created by sazid on 9/28/2024 in #questions
Is there any mutex available in the stdlibs?
66 replies
MModular
Created by sazid on 9/28/2024 in #questions
Is there any mutex available in the stdlibs?
it's taking inout self
66 replies
MModular
Created by sazid on 9/28/2024 in #questions
Is there any mutex available in the stdlibs?
No description
66 replies
MModular
Created by sazid on 9/28/2024 in #questions
Is there any mutex available in the stdlibs?
a small update: the fetch_add requires inout which is why the method itself needs to have inout.
66 replies
MModular
Created by sazid on 9/28/2024 in #questions
How to get unix timestamp?
fn time_ms() raises -> Int64:
@parameter
if os_is_linux():
time_ns = Int64(time._gettime_as_nsec_unix(11))
else:
var time = Python.import_module("time")
time_ns = Int64(time.time_ns())

var time_ms = time_ns // 1_000_000
return time_ms
fn time_ms() raises -> Int64:
@parameter
if os_is_linux():
time_ns = Int64(time._gettime_as_nsec_unix(11))
else:
var time = Python.import_module("time")
time_ns = Int64(time.time_ns())

var time_ms = time_ns // 1_000_000
return time_ms
This is what I ended up with for the time being.
23 replies
MModular
Created by sazid on 9/28/2024 in #questions
How to get unix timestamp?
I suppose, anything that starts with an underscore should be considered more experimental than other items?
23 replies
MModular
Created by sazid on 9/28/2024 in #questions
How to get unix timestamp?
sorry, I used the time._realtime_nanoseconds you're correct, the _gettime_as_nsec_unix(11) does not work in mac
23 replies
MModular
Created by sazid on 9/28/2024 in #questions
How to get unix timestamp?
this seems to be working for macos as well... m1 arm64
23 replies
MModular
Created by sazid on 9/28/2024 in #questions
How to get unix timestamp?
linux only will be okay too as long as it's possible to provide a fallback mechanism for other OSes via a compile-time parameter check... https://docs.modular.com/mojo/stdlib/sys/info/os_is_linux https://docs.modular.com/mojo/stdlib/sys/info/os_is_macos https://docs.modular.com/mojo/stdlib/sys/info/os_is_windows thanks for this, let me try it out
23 replies
MModular
Created by sazid on 9/28/2024 in #questions
Is there any mutex available in the stdlibs?
didn't know about the constrained, that's neat...
66 replies
MModular
Created by sazid on 9/28/2024 in #questions
Is there any mutex available in the stdlibs?
yes got it, thanks a ton!
66 replies
MModular
Created by sazid on 9/28/2024 in #questions
Is there any mutex available in the stdlibs?
oh yes!
66 replies
MModular
Created by sazid on 9/28/2024 in #questions
Is there any mutex available in the stdlibs?
isn't there still a little possibility that by the time the Atomic count is incremented and the result is calculated with the mask, the current_sequence may have changed?
66 replies