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 Жыл бұрын
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 Жыл бұрын
1:10 "Python programs also tend to use more RAM than applications built with C++" that one pointer in my code base:
@Tims_Projects Жыл бұрын
A great demonstration 👍
@programmingwithnick Жыл бұрын
Thank you Tim! Cheers!
@iWillAvert8 ай бұрын
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_MC7 ай бұрын
I really want to use PyPy, but you can't make an exe bundle with Pyinstaller, that's pretty annoying
@kyubi71662 ай бұрын
Pygamw is pypy compatible. Pygame is also CPU bound while rAylIB uses the gpu
@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Ай бұрын
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 Жыл бұрын
Have you used -O3 for C++? That alone can have a huge impact on the performance.
@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 Жыл бұрын
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 Жыл бұрын
@@programmingwithnick Strange, I expected at least some improvement. Was this flag also applied to the raylib library?
@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 Жыл бұрын
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!
@robertfletcher89648 ай бұрын
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-lr6cs5 ай бұрын
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
@GoatVibez6375 ай бұрын
Thanks for this, I wondered which language is better for game dev now. I don't anymore It's C++, btw
@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 Жыл бұрын
Good video. Have you ever used pyray?
@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Ай бұрын
Raylib with python bindings?
@YoutubePremium-fi3do Жыл бұрын
Hello nice video🙏 Can you give tutorial on circuit diagram of gaussmeter on softwares
@programmingwithnick Жыл бұрын
What do you mean? Can you please explain because I don't understand?
@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 Жыл бұрын
Are you building for desktop or for web? I had the same issue when building for web. The fps is limited.
@smanzoli Жыл бұрын
@@programmingwithnick building for desktop
@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 Жыл бұрын
Nice video, subscribed
@programmingwithnick Жыл бұрын
Thanks and welcome! I hope my channel is useful!
@gilian2587 Жыл бұрын
I was expecting 10-100x faster for the c++ version.
@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.
@johnnysmith47148 ай бұрын
In pygame you're making calls to C libraries, if you have a bunch of python loops you will see your 100x difference.
@DanFromIran10 ай бұрын
are you from the Netherlands? what is that accent?
@programmingwithnick10 ай бұрын
This accent is from Greece :-)
@DanFromIran10 ай бұрын
@@programmingwithnick Cool! Thanks for the content.
@tjn6278Ай бұрын
what is the difference in compiled file size?
@astrahcat121210 ай бұрын
Oooorrrr, you could make it in python with raylib, probably the fastest way to do it
@ViaConDias Жыл бұрын
A better comparison would be both languages used in Raylib
@programmingwithnick Жыл бұрын
You are right. I will give it a try! Thanks!
@ViaConDias Жыл бұрын
@@programmingwithnickSuper, then I don´t have to do it 🙂 Looking forward to seeing your results