Can Python be used for 3D programming?

Started by
7 comments, last by TheChubu 9 years ago

Hey there!

I've been wondering can Python be used for 3D? I mean, there are a lot of games in Java (say, Minecraft), JavaScript, etc. But is Python capable of running a 3D game (like, again, Minecraft) without lagging? If so which libraries would you reccomend (Pyglet, PyOGRE, PyOpenGL?).

Thanks.

Advertisement

Yes, it can be used for 3D programming.

Normally, computationally intensive functionality is turned into Python extensions and written in C/C++.

Panda3D is a good example (I think) of a good marriage between 3D game programming using Python and an efficient core written in C++.

Too many projects; too much time

Blender is written in Python, it's as 3D as you can get.

http://www.blender.org/

I've built a couple of 3D demos using Pyglet/OpenGL - it's a pretty nice language/toolkit combo to play around with.

I think Ashima IV is the only one in pure python - a number of the larger projects have significant C++ code to provide performance in key areas.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Blender is written in Python, it's as 3D as you can get.
http://www.blender.org/

Actually no, it exposes Python as scripting language but the core isn't written in Python: https://github.com/dfelinto/blender-git/ Hell, there it seems to be quite the amount of plain C there.

In any case, that Blender isn't written in Python has nothing to do with this, all you need is a GPU API binding (like PyOpenGL) and you're good to go. PyOpenGL is a binding for raw OpenGL, PyOgre seems to be a binding for Ogre rendering engine, which is a completely different thing.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

Blender is written in Python, it's as 3D as you can get.

http://www.blender.org/

Blender is actually mostly C++. If it was purely python, it would not run so well.

It uses python as an extension. Most of it's plugins and also some of it's main functionality is written in python however. But all python is used for is controlling it's logic. Not the actual computation.

Source: Actual source code repository.

You can make a 3D program completely from python. And it will run. But AI wouldn't expect anything complex being done in it, or it will run as slow as solidified tar.

Blender is written in Python, it's as 3D as you can get.

http://www.blender.org/

Blender is actually mostly C++. If it was purely python, it would not run so well.

It uses python as an extension. Most of it's plugins and also some of it's main functionality is written in python however. But all python is used for is controlling it's logic. Not the actual computation.

Source: Actual source code repository.

You can make a 3D program completely from python. And it will run. But AI wouldn't expect anything complex being done in it, or it will run as slow as solidified tar.

Well then, I guess I am going for Java :)

Take note that Java is faster but not all that much. It should be fine through unless you plan on making Halo or something.

Take note that Java is faster but not all that much.

I take issue with that:

http://benchmarksgame.alioth.debian.org/u64/compare.php?lang=python3&lang2=java

You'll find much bigger differences between Python and Java than between Java and C for example.

HotSpot is a very, very good VM. JIT output isn't an issue, it will use AVX if your CPU supports it, it can de-virtualize calls on the fly based on runtime profiling of the code, it can reorder branches and prune them if necessary based on which one gets executed the most, etc.

The issue generally lies in the amount of indirection which you find in common "idiomatic" Java code. Every object access is a pointer indirection, which is something you can have in mind for the lower layers while designing the project. Then again "pointer chasing" isn't an inherent issue of Java, its just something the language doesn't gives you many tools to mitigate. Java as it is lacks easy ways to control the memory layout of anything (except maybe abusing inheritance and direct buffers, which isn't pretty).

And on a side note, nobody is making Halo alone, regardless of the language used.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

This topic is closed to new replies.

Advertisement