Is PyPy often faster than C

If I am using PyPy, does it often times generate more efficient code than C?

shrug

That depends. What sort of code are you writing? Are you a brilliant C
coder who can write incredibly optimized and efficient C code, and a
terrible Python coder who writes poor, inefficient Python code? Or
perhaps the other way around?

PyPy uses a JIT compiler, so it needs time to warm up. It needs to run
your code and discover the “hot spots” that can be optimized at run
time. That means that PyPy is best for code that has large, complex
loops that get executed many times, not for short scripts.

I have to ask, what sort of code are you writing that you care so much
about all this stuff? Have you profiled your code to see what the
bottlenecks are, so that you can concentrate on speeding up the parts of
the code that matter, instead of spending days optimizing
code that saves you only 0.1 millisecond?

If you explain what your intention is, and your previous coding
experience, we can probably advise whether Python will be a good fit.

Well with anything really. For game development.

I don’t think C# and Java are good languages at all for game development because comapred to something like Rust, I have noticed that the movement would keep stopping and starting and this is due to GC, I hope its not the same case with PyPy?

I heard micropython for some some small embedded computer. Does it use PyPy?

If you are a very good and experienced C programmer as well, would PyPy still beat C code?

Game development covers everything and anything from text based games,

to Solitaire, to massive multiplayer world builder games, to 3D first

person shooters, and more.

I probably wouldn’t try to write the graphics engine of a 3d first

person shooter in pure Python, but Python is perfectly fine for many,

many games. I recommend you start here:

https://www.pygame.org/

to learn more about game development and programming.

Micropython does not use PyPy. PyPy wouldn’t even run on the sort of

tiny embedded systems that Micropython is designed to use.

As far as PyPy versus C goes, it is not "PyPy programmer versus C

programmer" which matters, it is PyPy JIT compiler versus C compiler"

that matters. A lousy C compiler will produce lousy code. An excellent C

compiler with lots of optimizations will be faster than nearly anything

PyPy can do, with a few carefully crafted exceptions.

1 Like

How do you know that? Are you assuming? Are you sure the executable was built for production (not debug)? Like PyPy, garbage collection in C# is not instantaneous. And like PyPy C# uses a JIT compiler.

I have actually built a couple of stuff from Unity C#, I have played an Android game (not designed by me) that was designed in Unity, all of them had the same very slight stuttering effect.

And using both Rust and Processing lang, I made a simple circle move around the screen and this very slight stuttering effect was occuring in Processing but not in Rust.

With both Processing I did release it as production ready, and for Unity I built the executable for final release. So yes it looks like GC process keeps occuring, while the stuttering effect is very slight, it happens a lot of the times and it is noticeable.

For general software (that doesn’t require high performance) I would say GC is fine, but for game development, you may want to look else where as it is noticeable.