Can Python Approach the Speeds of C?

  Рет қаралды 5,277

Daniel Boctor

Daniel Boctor

Күн бұрын

In this video, we explore a HUGE gamechanger for Python speed and optimization - Just In Time compilation (JIT) with Numba.
WE HAVE A DISCORD NOW! / discord
Source code - github.com/daniel-boctor/Dani...
0:00 - Intro
0:52 - Compilation vs interpretation
2:05 - Numba (JIT)
2:36 - Decarators
3:58 - NumPy

Пікірлер: 22
@DanielBoctor
@DanielBoctor 7 ай бұрын
WE HAVE A DISCORD NOW
@sanderbos4243
@sanderbos4243 8 ай бұрын
So cool that you can just slap such a short decorator on your functions to do it with Numba
@DanielBoctor
@DanielBoctor 8 ай бұрын
I know! It really is something
@Proprogrammer001
@Proprogrammer001 8 ай бұрын
I will share this with people just by virture. The meme you put at 1:05. Brilliant animations.
@DanielBoctor
@DanielBoctor 8 ай бұрын
Thanks for the feedback. Appreciate the shares too. Your a real one
@user-pl1wx4zv1m
@user-pl1wx4zv1m Ай бұрын
That decorator is amazing, but the speed up in this case happens because it compiles the code and knows the answer beforehand If you will try the same example in c++ for example (you might need to use constexpr) you will see that the assembly code will be only a couple of lines because the compiler does all the work on the background
@tahaelaminekassabi5720
@tahaelaminekassabi5720 8 ай бұрын
bro using java logo for js 1:02.
@TheControlMastr
@TheControlMastr 7 ай бұрын
Congratulations Daniel! You managed to lose me the first 10 seconds. I have to come back to this video after CS50 class 😅 Amazing Video!
@DanielBoctor
@DanielBoctor 7 ай бұрын
LOOOOOOOOL you're a real one @TheControlMastr
@KalleLast
@KalleLast Ай бұрын
a few months late but I implemented the same simple function and ran it on my machine and used 10,000 for the parameter value. ~3 trillion ns for pure python vs 1.4, 1100, 370 and 250ns for four consequitive runs for the jit version (speed didn't change much after that and hovered around 250). Running the same algorithm in c++ with -O2 it seemingly just optimized it to constant-time calculation as it ran in 10-20ns both when using 10,000 and 100,000 as the parameter. I wonder what could be a better microbenchmark that shows how well the jiting works for python and how close to c/c++ it can get.
@brockobama257
@brockobama257 8 ай бұрын
I knew it would be numba. Cool thing is if you have some complicated shit to do you can use cmake to create your own package.
@Darkev77
@Darkev77 5 ай бұрын
Very interesting; I personally use Cython's Pure Python mode to compile time-intensive Python functions, and I wonder how it compared to Numba
@komitetgosudarstvennoybezo5097
@komitetgosudarstvennoybezo5097 Ай бұрын
JavaScript Java logo very epic
@ImperialRoads
@ImperialRoads 8 ай бұрын
this taught me how little chicken wings float in the equator of the earth
@erikkonstas
@erikkonstas 8 ай бұрын
This is simply not possible, a script running under a VM will never be as fast as a native executable with the same algorithm and task...
@Ceelbc
@Ceelbc 8 ай бұрын
It does not work in python 1.12.
@josebr0
@josebr0 3 ай бұрын
Thing is, numba isn't 100% compatible with numpy. Try using argmin or argmax. It simply doesn't work in nopython mode. It's really a shame.
@chenuka223
@chenuka223 Ай бұрын
Bros using Java logo on JavaScript
@manupro1698
@manupro1698 8 ай бұрын
Why Python is faster? Because is using c
@greenwaldian
@greenwaldian 8 ай бұрын
I don't get it
@SimGunther
@SimGunther 8 ай бұрын
​@@greenwaldianJIT is not (usually) C: numba is aware of the platform running the code in order to create the correct machine code in a write-executable block of memory that represents the function defined as python code. When defining I/O heavy code, the performance boost from JIT is negligible compared to math heavy code.
@myname-mz3lo
@myname-mz3lo 4 ай бұрын
hacking tools are about to get much faster
Is Your Python Code Unsafe? GIL’s Hidden Secret
12:00
Daniel Boctor
Рет қаралды 5 М.
Python 3.12 is HERE!
12:37
mCoding
Рет қаралды 155 М.
The delivery rescued them
00:52
Mamasoboliha
Рет қаралды 6 МЛН
Заметили?
00:11
Double Bubble
Рет қаралды 3,1 МЛН
Do you have a friend like this? 🤣#shorts
00:12
dednahype
Рет қаралды 53 МЛН
5 Good Python Habits
17:35
Indently
Рет қаралды 348 М.
Compiled Python is FAST
12:57
Doug Mercer
Рет қаралды 91 М.
How Fast can Python Parse 1 Billion Rows of Data?
16:31
Doug Mercer
Рет қаралды 156 М.
The Hacker who could turn on ANYONE'S Zoom Camera [Zero-Day]
14:17
Daniel Boctor
Рет қаралды 76 М.
THIS is Why List Comprehension is SO Efficient!
5:25
b001
Рет қаралды 168 М.
Dev Loses $440 Million in 28 minutes, Chaos Ensues
10:17
Daniel Boctor
Рет қаралды 196 М.
Async for loops in Python
16:36
mCoding
Рет қаралды 56 М.
Cython makes Python INSANELY FAST
19:08
Carberra
Рет қаралды 32 М.
Дени против умной колонки😁
0:40
Deni & Mani
Рет қаралды 10 МЛН
POCO F6 PRO - ЛУЧШИЙ POCO НА ДАННЫЙ МОМЕНТ!
18:51
5 НЕЛЕГАЛЬНЫХ гаджетов, за которые вас посадят
0:59
Кибер Андерсон
Рет қаралды 1,2 МЛН
ЭТОТ ЗАБЫТЫЙ ФЛАГМАН СИЛЬНО ПОДЕШЕВЕЛ! Стоит купить...
12:54
Thebox - о технике и гаджетах
Рет қаралды 146 М.