Speed Comparison - Python VS Go

preview_player
Показать описание
Today we compare Python and Go in terms of execution speed.

◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
📚 Programming Books & Merch 📚

💻 Exclusive Content 💻

🌐 Social Media & Contact 🌐

Рекомендации по теме
Комментарии
Автор

Python : 165 MS
Go : 31 MS

Python : 225 MS
Go : 18 MS

alpw
Автор

i way prefer go but have to admit comparing a compiled language to an interpreted one is kind of unfair

wkdj
Автор

good video.

at 14:25 tho, we can see that the python script is still making a 10000 element list which you forgot to change to 1000 which sorts only the first 1000 elements, so yeah just wanted to let you know. i tested it on my laptop (aka toaster with ubuntu 20 installed).
here are the results:
1000, 1000 = 145 ms
1000, 10000 = 134 - 135 ms

very small diff but i just got curious and i said might as well post it here too

again, good job.

mehregankbi
Автор

If you'd use numpy for low lvl tasks like this you could use the power of C

Liproqq
Автор

Sorting 100k elements in Python the right way:
>> import numpy as np
>> np.sort(np.random.randint(0, 100, 100_000))
~ 4.54 ms

dmytrokorbanytskyi
Автор

Please make a java vs go speed comparison video.

shravanasati
Автор

I think you made a mistake at 14:00. In the definition of function you've written a thousand but in the script part you wrote 10000. However I'm sure that Golang wins most of the rounds against python (without pypy) :). Also great video and channel!

ethemylmaz
Автор

go is known for concurrency
if u dont use that its pretty much slower C/C++

rando
Автор

Very useful. I will be using GO because for my current need, speed an maintainability is everything. GO wins on both.

jackt
Автор

Would like to see a remake of this video for Python 3.11 with that now being out.

MaJetiGizzle
Автор

Speed comparison is usually performed via manipulating with numbers. Python can use numba/taichi decorators or cython to handle them quickly.
Practically we work with text more. Here the cython or jit compilers become useless or harder to implement. Go and other compiled languages can work faster with text, but the difference is much smaller (still big though).
So python is slow in runtime, while it has ipython/jupyter and tons of libraries. So it’s faster in developments and good for small applications. When the app becomes bigger - the architecture is more clear and can be ported to another language.

gvozdyara
Автор

comparing vanilla python on speed (using for loops) makes little sense. Any program with for loops that needs to run fast can simply be decorated (aided) with the numba JIT compiler. All you need is to import "numba" and then add a single-line decorator to precompile any speed-sensitive function to machine language. Such decorator also allows parallelization of the loops because it includes thread-safe aggregating functions such as sum, update vectors, and many And for matrix operations, python has numpy module which performs vector/matrix math operations at utmost optimized speed.

chriswysocki
Автор

Cool video. I went to replicate this myself and had a question. In the go docs it says that Duration is in nanoseconds and Python time.time() is in seconds. Did I get this mixed up?

codywikman
Автор

The most part of python code is just looping through the for loop buiding the list.. is not actually sorting... sorting in python is quite fast since the "sort" function is written in C...
So, you said that python takes way more time sorting, but that's not really the case here

AgustinMarquezBraconi
Автор

Awesome video, keep up the incredible work! :)

ComputerScienceSimplified
Автор

Hope u'll grow fast, THX for your work.

tonypittella
Автор

Obvious results if you are interpreting python, it would be slower. I run same code in 82 ms average on 100 runs (yours 160-170ms) and with numba python JIT (just one decorator over function) got 4.85ms average, so it would be ~9-10ms on your system, faster than Go.
With your bubble sort for 10000 it took 115ms as is, 15ms with numba JIT

rouol
Автор

NeuralNine How did u think is it worth learning GO now? Now i know Python basics, and i would like to learn GO, but i don't know if this language will be in demand in 5-10 years. And sorry for my bad english)

fluffis
Автор

Results from end of 2022. Python 3.10, Go 1.18.
First algorithm (just creating random numbers and built-in sort)
Python 50 ms --- Go 10 ms.

enisarik
Автор

Damn, you know the length of slice and you didn't preallocate it in Go

alexanderp