Mojo hand-written hash map dictionary versus Python and Julia

  Рет қаралды 1,272

EKB PhD

EKB PhD

Күн бұрын

I test the speed of a hand-written hash map dictionary in Mojo language against Python and Julia. The hand-written hash map dictionary is much quicker (9x) than Mojo's native dictionary data type, and slightly quicker than Python, but both are slower than Julia.
Here's my Mojo script:
github.com/ekbrown/scripting_...
Here's my Python script:
github.com/ekbrown/scripting_...
Here's my Julia script:
github.com/ekbrown/scripting_...
Here's the Mojo hand-written hash map dictionary github repo:
github.com/mzaks/mojo-hash
Here's the question I asked on Mojo's official github repo:
github.com/modularml/mojo/dis...
#mojolang #julialang #python

Пікірлер: 6
@mariusdrulea9049
@mariusdrulea9049 3 ай бұрын
If you do this little change in your julia code, the runtime would be even faster: wds = String.(split(txt, " ")). This will eliminate the allocations happening inside the loop, cause SubStrings were converted to Strings inside the loop. Now we do this outside of the loop. I also recommend benchmarking with the @time macro.
@ekbphd3200
@ekbphd3200 3 ай бұрын
Thanks for the tips! I appreciate them. I'll look at implementing this soon.
@ekbphd3200
@ekbphd3200 3 ай бұрын
I tried what you suggested, but it actually took longer. See below: ### 27 seconds on average ### t1 = now() wds = split(txt, " ") freqs = Dict{String,Int}() for wd in wds freqs[wd] = get(freqs, wd, 0) + 1 end t2 = now() ### 40 seconds on average ### t1 = now() wds = String.(split(txt, " ")) freqs = Dict{String,Int}() for wd in wds freqs[wd] = get(freqs, wd, 0) + 1 end t2 = now() Do you see something I could do better?
@exxzxxe
@exxzxxe 5 ай бұрын
Excellent! What about Rust?
@ekbphd3200
@ekbphd3200 4 ай бұрын
Rust kicks butt: kzfaq.info/get/bejne/fZuFiayI39ythnk.html
@exxzxxe
@exxzxxe 4 ай бұрын
@@ekbphd3200You, sir, are a gentleman and a scholar.
Julia vs. Python when calculating lexical diversity
10:17
Spot The Fake Animal For $10,000
00:40
MrBeast
Рет қаралды 183 МЛН
What it feels like cleaning up after a toddler.
00:40
Daniel LaBelle
Рет қаралды 84 МЛН
Опасность фирменной зарядки Apple
00:57
SuperCrastan
Рет қаралды 11 МЛН
Python Hash Sets Explained & Demonstrated - Computerphile
18:39
Computerphile
Рет қаралды 113 М.
Mojo Is FASTER Than Rust
19:22
ThePrimeTime
Рет қаралды 113 М.
Why is Mojo's dictionary slower (!) than Python's?
12:16
EKB PhD
Рет қаралды 4 М.
How much faster has Mojo's dictionary gotten?
7:40
EKB PhD
Рет қаралды 2,5 М.
Mojo 🔥 - Новый язык, который заменит Python?
11:53
How I'd Learn AI (If I Had to Start Over)
15:04
Thu Vu data analytics
Рет қаралды 762 М.
What is Different About the Julia Programming Language? | Stefan Karpinski | JuliaHEP 2023
45:36
Choosing Your Language: Python or Mojo?
14:33
ArjanCodes
Рет қаралды 112 М.
Mojo - the BLAZINGLY FAST new AI Language? | Prime Reacts
25:18
ThePrimeTime
Рет қаралды 171 М.
Spot The Fake Animal For $10,000
00:40
MrBeast
Рет қаралды 183 МЛН