Python vs C++ -speed

I know,python is an interpretive language,so compiled C++ code is A-LOT faster.But anyway,I would like to here from you guys.Python and C++ in Panda3d.How much faster is C++?Any example or benchmark comparison?

I don’t have any examples right now, but what I recommend is always writing your main code in Python and the little but often repeated “sub-routines” in C/C++.
It’s the best way to use both Python’s accessibility(program development speed in terms of time needed to write a program), and C’s execution speed.

I dont know C.Never tried to learn it.But how about Python code?Speed OK?Like compared to BlitzBASIC?

you can look at this page if you want to have some benchmark:

Python is pretty speedy, as interpreted languages go. It’s not the fastest in the world, nor is it the slowest.

The short answer is, Python is “fast enough”. If you write your application in Python and find it’s too slow, it’s usually because you’re doing something stupid, but you can do something stupid in any language.

Very occasionally, the language just isn’t fast enough for what you want to do. For instance, processing thousands of individual vertices every frame, or thousands of individual pixels, would probably be a mistake to do in Python, or any interpreted language. But the design of Panda tries to be such that you generally don’t need to do this sort of thing in Python–Panda will do it for you.

But Python is so easy to code in, you will find you save vast man-hours of work in development time. This time is so much more valuable than CPU time these days, that it’s more than worth the tradeoff.


I saw pretty good games made with panda3d.But you just cant know if it is coded in Python or C.Any chance Python will become a compiled language one day,like BASIC?Just asking…

“Any chance Python will become a compiled language one day,like BASIC?”

I did not know how can some one say so many things that bother me in one sentence.

Langauges cant be compiled or not compiled only their implementations can be compiled or interpreted.

BASIC is a language with too many dialects and some of them are pretty slow and not compiled.

Python is compiled to byte code like java or c#. Just the virtual machine the byte code runs on is more high level. Iron Pyhton and Jethon get compiled to CLR and JVM…

Python can be compiled (almost as is) with pyrex to native machine code but the speed up is small because it has to call the same functions, weather you call the functions with code or opcodes not big difference.

Python can be just-in-time compiled with psyco which does optimizations which can speed up python x10 fold.

The new pypy project has even cooler goals!

Yeah I know python can be compiled,but it turns into ‘bytecode’.Its still slower.Ive heard its even easy to ‘decompile’ it.That pypy project sounds interesting…

Disney’s Toontown Online and Pirates of the Caribbean Online are both written in plain old ordinary Python, plus Panda3D. Judge for yourself whether their performance is satisfactory.


They are awesome.If i knew the system requirments it would look even more awesome.

System requirements for both games are published on their respective webpages. They are modest.


it’s difficult to say any one language is slower then any other language. it depends on what you’re doing. that said, c/c++ will probably always run faster and consume less memory then python to do the same thing.

it doesn’t matter though. a good rule of thumb is always use the highest level language you can get away with. python is a beautiful language, and it allows the programmer to be vary productive. in c/c++ you have a lot of details to deal with, and it can truly be a pain in the ass.

i assume you have a project in mind and want to know if python will be fast enough to meet your needs. knowing nothing about what that project might be, i can say with some certainty that it is. if your project is running slow in python, chances are your code is not well thought out. going lower level in c will just exacerbate the real problem.

i’m operating under the assumption that you’re a relatively inexperienced programmer, if i’m wrong then my bad.