C++ Raylib VS Python Pygame Speed Comparison

  Рет қаралды 22,979

Programming With Nick

Programming With Nick

Күн бұрын

C++ Raylib VS Python Pygame Speed Comparison
I developed the same game in C++ & raylib and in Python & Pygame. Which one is faster?
C++ Code: github.com/edu...
Python Code: github.com/edu...

Пікірлер: 43
@programmingwithnick
@programmingwithnick Жыл бұрын
Did you find this video helpful? Share your thoughts in the comments section below. Also, check out this exciting Android game called 'Quiz of Knowledge' by clicking on this link: bit.ly/QuizOfKnowledge. You'll surely love it!"
@KachiYES
@KachiYES Жыл бұрын
1:10 "Python programs also tend to use more RAM than applications built with C++" that one pointer in my code base:
@Tims_Projects
@Tims_Projects Жыл бұрын
A great demonstration 👍
@programmingwithnick
@programmingwithnick Жыл бұрын
Thank you Tim! Cheers!
@iWillAvert
@iWillAvert 8 ай бұрын
Not sure what the state of this was at the time of this video, but as of now, raylib has bindings for Python. It's compatible with PyPy (RPython) and they recommend in *most* cases that you use that since it is JIT compiled. Curious to see how different the performance is of the direct comparisons, rather than raylib vs pygame. On that note, I'm also kind of curious the performance difference between raylib and pygame both using Python. I would imagine it's pretty large since I do not think that pygame is PyPy compatible, though I could be wrong. I have all of that so I'll probably just test it myself, and maybe update this comment when I get the answers (if I remember)!
@system64_MC
@system64_MC 7 ай бұрын
I really want to use PyPy, but you can't make an exe bundle with Pyinstaller, that's pretty annoying
@kyubi7166
@kyubi7166 2 ай бұрын
Pygamw is pypy compatible. Pygame is also CPU bound while rAylIB uses the gpu
@estranhokonsta
@estranhokonsta Ай бұрын
My first reaction when seeing the title is: Really? Is there really a need for this type of video? Was ever there a doubt about the difference between the two? Maybe this is a troll video? So i took a look at it. It is very serious in explaining such an obvious thing. And then i remembered that a long time ago (before the internet and all) i also would want someone to tell me exactly all of these details. And then i realize how dumb i was being with my "first reaction". I am getting grumpy with age. Thankfully i still have a "second reaction" that follows it soon after. Kudos to the author for making the effort to help random other people from all overt he world.
@programmingwithnick
@programmingwithnick Ай бұрын
You have a great antidote to the "Curse of Knowledge." It's easy to forget how it felt not knowing something once we become familiar with it. Your 'second reaction' shows real self-awareness-remembering that not everyone is at the same stage of learning. Thanks for the reminder to stay patient and open-minded as we share knowledge.
@perelmanych
@perelmanych Жыл бұрын
Have you used -O3 for C++? That alone can have a huge impact on the performance.
@programmingwithnick
@programmingwithnick Жыл бұрын
You are right. I didn't set it -O3. I will do it, and I will get back with another video. Thank you very much for the tip!
@programmingwithnick
@programmingwithnick Жыл бұрын
I just run the game with the -O3 flag. The FPS remained in same range. So, there is no significant advantage from this change.
@perelmanych
@perelmanych Жыл бұрын
@@programmingwithnick Strange, I expected at least some improvement. Was this flag also applied to the raylib library?
@programmingwithnick
@programmingwithnick Жыл бұрын
You are right, now that I checked again, the raylib library was compiled with -01 so I need to recomplile it and try again. Thanks again.
@programmingwithnick
@programmingwithnick Жыл бұрын
I tried again and compiled raylib with the -O3 optimization flag. This time, I noticed an big improvement in speed. Now the game runs always at above 5000 fps and at times it reaches 6000 fps. So, the range is like 5000 - 6000 fps, so C/C++ is 5-6 times faster in this example. I will prepare a follow up video. Thanks for the tip!
@robertfletcher8964
@robertfletcher8964 8 ай бұрын
This is a nice example but I suspect the gulf between Python and C++ is enormously wider than this test demonstrates. Once more complex game logic, and more mathematical computation is required pythons performance will degrade far faster than C/C++. Every call in python is more expensive than C++ and in allot of cases there is translation layer converting native C/C++ to PyObjects when you call game engine functions. PyGame is awesome for simple stuff but It cant scale like Raylib (and thats totally fine)
@Phantom-lr6cs
@Phantom-lr6cs 5 ай бұрын
even if pygame was faster still it'll not be as faster as c++ written game unless developer does some stupid things in his own c++ app
@GoatVibez637
@GoatVibez637 5 ай бұрын
Thanks for this, I wondered which language is better for game dev now. I don't anymore It's C++, btw
@burnttoast111
@burnttoast111 Жыл бұрын
Also there can be hardware bottlenecks which can affect test results. Just consider this simple hypothetical: Imagine you have a video card which just drawing these elements nonstop results in 100 fps. The card literally can't draw faster. All the game logic in Raylib might introduce delays of 1/100th of a second in sending draw calls to the video adapter, which results in 99 fps. At 1/10th the speed, Pygames might causes 1/10th of a second worth of delays sending draw calls to the video adapter, resulting in 90 fps. So while Raylib is 10x faster than Pygames in this hypothetical, the fps performance gain is only 10% (from 90 to 99 fps). Just something to consider. In testing software, there is a reason why it should be done on a variety of hardware, especially for games.
@bldn271
@bldn271 Жыл бұрын
Good video. Have you ever used pyray?
@beef623
@beef623 Жыл бұрын
I know the results won't be much different, but I'd like to see c++ raylib vs Python raylib and/or pygame vs Python raylib.
@SusumoKakinotane
@SusumoKakinotane Ай бұрын
Raylib with python bindings?
@YoutubePremium-fi3do
@YoutubePremium-fi3do Жыл бұрын
Hello nice video🙏 Can you give tutorial on circuit diagram of gaussmeter on softwares
@programmingwithnick
@programmingwithnick Жыл бұрын
What do you mean? Can you please explain because I don't understand?
@smanzoli
@smanzoli Жыл бұрын
how did you unlimit the fps?? When I use Raylib with C, the max fps I get is limited my my monitor refresh rate, so I cannot go above 75. Does not matter if I use SetTargetFPS(240), for example (even drawing only a single circle). Also, when I try the same algorithm to draw N moving balls on the screen, I get C Raylib as fast as P5JS, but half the speed I get with Pygame2. And, repeating, limited to my monitor, only in C Raylib.
@programmingwithnick
@programmingwithnick Жыл бұрын
Are you building for desktop or for web? I had the same issue when building for web. The fps is limited.
@smanzoli
@smanzoli Жыл бұрын
@@programmingwithnick building for desktop
@smanzoli
@smanzoli Жыл бұрын
@@programmingwithnick I've just turned G-Sync off in NVIDIA Control panel, and now C Raylib is free to go above my monitor refresh rate!
@DWM864
@DWM864 Жыл бұрын
Nice video, subscribed
@programmingwithnick
@programmingwithnick Жыл бұрын
Thanks and welcome! I hope my channel is useful!
@gilian2587
@gilian2587 Жыл бұрын
I was expecting 10-100x faster for the c++ version.
@StarFury2
@StarFury2 Жыл бұрын
This is simple program with only few checks on each frame, so speed difference is not that dramatic. If instead of one bouncing ball we have thousands, C++ would be superfast to loop through those. In my testing, for this scenario, C++ is 30x faster than python.
@johnnysmith4714
@johnnysmith4714 8 ай бұрын
In pygame you're making calls to C libraries, if you have a bunch of python loops you will see your 100x difference.
@DanFromIran
@DanFromIran 10 ай бұрын
are you from the Netherlands? what is that accent?
@programmingwithnick
@programmingwithnick 10 ай бұрын
This accent is from Greece :-)
@DanFromIran
@DanFromIran 10 ай бұрын
@@programmingwithnick Cool! Thanks for the content.
@tjn6278
@tjn6278 Ай бұрын
what is the difference in compiled file size?
@astrahcat1212
@astrahcat1212 10 ай бұрын
Oooorrrr, you could make it in python with raylib, probably the fastest way to do it
@ViaConDias
@ViaConDias Жыл бұрын
A better comparison would be both languages used in Raylib
@programmingwithnick
@programmingwithnick Жыл бұрын
You are right. I will give it a try! Thanks!
@ViaConDias
@ViaConDias Жыл бұрын
@@programmingwithnickSuper, then I don´t have to do it 🙂 Looking forward to seeing your results
C++ Space Invaders Tutorial with raylib - Beginner Tutorial (OOP)
2:26:20
Programming With Nick
Рет қаралды 23 М.
Compile C/C++ raylib game Into WebAssembly
16:07
Programming With Nick
Рет қаралды 17 М.
Cute
00:16
Oyuncak Avı
Рет қаралды 12 МЛН
Will A Guitar Boat Hold My Weight?
00:20
MrBeast
Рет қаралды 229 МЛН
From Small To Giant Pop Corn #katebrush #funny #shorts
00:17
Kate Brush
Рет қаралды 68 МЛН
How I made a world with trillions of gems in C with Raylib
10:09
Lingon Studios
Рет қаралды 14 М.
🔥Pong Game with C++ and Raylib - Beginner Tutorial
42:30
Programming With Nick
Рет қаралды 53 М.
6. Создаем игру "Тетрис" на Python используя библиотеку Pygame #python #pygame #игразмейка
24:11
ITMouse: международная школа программирования
Рет қаралды 335
Learning C++ and making a GAME WITHOUT A GAME ENGINE
9:40
Chadderbox
Рет қаралды 105 М.
Making a Game With C++ and SDL2
8:14
PolyMars
Рет қаралды 1,7 МЛН
Load OBJ Files - Raylib Tutorial
13:45
Avery
Рет қаралды 13 М.
Creating a game in C and Raylib in 1 year - Making of Sidestep Legends
23:35
Raylib Game Development Tools -- Work With Any Game Engine!
11:54
Gamefromscratch
Рет қаралды 36 М.
Get Started in raylib in 20 minutes!
21:05
Programming With Nick
Рет қаралды 15 М.
Cute
00:16
Oyuncak Avı
Рет қаралды 12 МЛН