Python for Mudlet

Aico
Posts: 27
Joined: Wed Jan 20, 2010 3:46 pm

Python for Mudlet

Post by Aico » Tue Feb 07, 2012 4:32 am

I replied to a thread a few months back where I showed a mudlet mod with python support that I had just made. I have decided to create a topic on it since it has grown from mudlet with just a barebone interpreter installed to currently supporting most of the features that can be found in the lua api. I owe much thanks to KrimMalak for the help with adding in a lot of the python functions.

The source can be cloned from:
git://github.com/Aico/mudlet.git

supported:
  • Lua api equivalent python functions.
  • full mapper support in python.
  • Python coexists with Lua so you can use both.
not supported:
  • Lua and Python do not share variable space.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Python for Mudlet

Post by Heiko » Tue Feb 07, 2012 8:17 am

Is your repo in sync with the latest mudlet release in the main sf.net repository? When the repo is in sync and if it compiles on windows and macs (please update mac_src.pro) I'll try to merge the python support. Which GPL compliant Python package do you want to ship with with windows build?

Aico
Posts: 27
Joined: Wed Jan 20, 2010 3:46 pm

Re: Python for Mudlet

Post by Aico » Tue Feb 07, 2012 2:38 pm

I will work on syncing to the sf repo. The last time I merged from sf was in July so I will need to work with half a year of changes. Luckily most of the additions are confined to the Python specific classes so the process shouldn't be too much of a problem. I'll also test it out in Windows, the last time I tried that a few months ago, the way to compile for windows wasn't quite worked out yet, but I see now that some have claimed success. Theoretically, since the only additional requirement for an ubuntu compile is python-dev, so I'll expect I'll be able to follow the Windows compiling instructions others have worked out. As for mac, I'll attempt to update the mac_src.pro, but I don't have an easily accessible mac so I'll have to see if someone could help me with that.

User avatar
Rakon
Posts: 350
Joined: Tue Feb 16, 2010 7:41 pm
Contact:

Re: Python for Mudlet

Post by Rakon » Wed Feb 08, 2012 1:00 am

Sounds like some great work, and good progress. I'd love to see completion of python support for Mudlet. I'd surely make use of it and let you know of bugs.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Python for Mudlet

Post by tsuujin » Wed Feb 08, 2012 4:26 pm

Merge? Wouldn't it slow us down trying to run two interpreters simultaneously? Also, make variable interpretation more complicated?

Aico
Posts: 27
Joined: Wed Jan 20, 2010 3:46 pm

Re: Python for Mudlet

Post by Aico » Wed Feb 08, 2012 5:10 pm

tsuujin wrote:Merge? Wouldn't it slow us down trying to run two interpreters simultaneously? Also, make variable interpretation more complicated?
The Python interpreter can be turned off in Settings, then it will be exactly the same as the current mudlet. As for the second point, since the the two interpreters do not share variables, there really isn't any ambiguity, if you're writing a Lua script, you can't access Python variables directly even if you wanted to.

User avatar
chris
Posts: 493
Joined: Fri Jun 17, 2011 5:39 am

Re: Python for Mudlet

Post by chris » Thu Feb 09, 2012 1:44 am

I love python. This rocks. Do you have a dynamic way of keeping in sync with the lua interpreter function calls?

Aico
Posts: 27
Joined: Wed Jan 20, 2010 3:46 pm

Re: Python for Mudlet

Post by Aico » Thu Feb 09, 2012 4:12 am

chris wrote:I love python. This rocks. Do you have a dynamic way of keeping in sync with the lua interpreter function calls?
Currently no.

User avatar
chris
Posts: 493
Joined: Fri Jun 17, 2011 5:39 am

Re: Python for Mudlet

Post by chris » Thu Feb 09, 2012 4:39 am

One way could perhaps just having a python.callLua(...) function which will reroute to the called function. Then all you need to do is reinterpret the output (tables->dict and everything else is automatic typing more or less).

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Python for Mudlet

Post by Heiko » Thu Feb 09, 2012 11:46 am

tsuujin wrote:Merge? Wouldn't it slow us down trying to run two interpreters simultaneously? Also, make variable interpretation more complicated?
Of course we need to make sure that there is no significant performance loss. I haven't looked at the python code for several months so there may be issues that have to be changed.

Generally speaking having 2 scripting languages has little impact on the over all performance as scripts are marked on an object level as to which interpreter they belong to and then run in the appropriate interpreter which, in turn has its own variables. Consequently, Mudlet events are not an issue as well as all types of object scripts. The few Lua call backs that are still being used should be moved to events anyways.

The only area that needs to be especially taken care of is ATCP and GMCP variables as setting them twice for 2 different interpreters clearly has a negative impact on performance - especially as GMCP traffic can be quite substantial. Here we need to carefully look at all the available options and do some benchmark tests before we come up with a solution. There will certainly be options to disable Lua or Python GMCP/ATCP support as well as entirely disabling all Python scripting support for those who want maximum performance.

All things considered, Python scripting support imho is a very nice feature and I'm sure that many users will like it.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest