Jump to content

Python Integration?


TonyF
 Share

Recommended Posts

I see this come up every now and then over the years with most engines and thought its a great idea.

 

Im aware Panda3D is python based which was a bit of fun but it is also nice to have an editor such as leadwerks in the mix.

 

I understand the choice for lua as a permanent commercial solution (Simpler, low interpreter overhead) but i could never let it catch on.

 

Python on the other hand has a fair bit more overhead as you would imagine compared to lua but it also opens up plenty of added advantages (Simple & Complex, plenty of support libraries ie networking etc, 'smarter' code editors with auto complete, sometimes friendlier debugging)

 

I will say that originally i absolutely hated python. I thought it looked ugly and the lack of braces made my head explode coming from predominantly a C++ and PHP background (amongst many others but these primarily). Eventually i started to properly try it and now i program with almost nothing BUT python these days. Personally i feel like its 'a lazy scripted c++' and although that sounds 'bad' its actually quite a compliment.

 

I know previously i had several performance issues with Leadwerks last year that couldnt be explained (game coded completely in c++ and lag with only a few DLC zombies. The lua project was the same) although now that i have installed windows 10 and brought a new graphics card i thought it was time to play again.

 

Now with that spiel i thought i would do a prototype instead of being another person asking for it.

 

The project goal for me is to embed a python interpreter and create an interface wrapper to the leadwerks header and create a python interface api. (Major pain)

 

The ultimate goal for me is to be able to quickly script ideas, tests, prototypes for my game together, test with a debugging environment better than visual studio (IMO), watch updates to the script run instantly without restarting the game. (Classes can be injected at runtime with some python magic added or do a quick reload)

 

The added advantage of using python with the same API is that i can very easily convert the code to C++ for the final commercial product or for speed. (albeit with the additions of adding any supported libraries ie networking with twisted however the concept is proven)

 

 

The end result is a minimum 2 python scripts that get called (Which matches the app.h)

startup.py

runtime.py

 

Lua scripts still work as normal

 

The C++ side profiles and outputs the python execution time into the python namespace as well which helps determine some bottlenecks

post-13674-0-92224500-1445406672.png

post-13674-0-80153600-1445406682_thumb.png

post-13674-0-77353400-1445406703_thumb.png

  • Upvote 8
Link to comment
Share on other sites

  • 2 weeks later...
  • 10 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...