Why not to make new programming in Blender ?

How much faster?
The most popular implementations for both run interpreted bytecode in a VM written in C.

test test test

I think lua is more fast than python, but i give you links :

Lua vs Python from the quote :
Faster interpreter (Lua vs. Python) and faster JIT compiler (LuaJIT vs. Psyco )

  • How about PyPy??

and for perfomance, compare it.

The reference implementation isn’t much faster than CPython, but LuaJIT (with JIT enabled) is about a magnitude faster in minilight and it’s close to native in some microbenchmarks. It also has a very efficient C FFI.

I don’t have numbers, but I’d expect LuaJIT to be among the most popular implementations.

PyPy isn’t all that great. For one, the (CPython-compatible) C bindings are quite slow, so re-using the existing Python backend would likely result in worse performance. Also, PyPy’s focus is still on Python 2, while Python 3 support lags behind a lot (and is lacking in funding).

As always, for speed YMMV depending on the task, but testing nested for loops is quite a simple micro-benchmark.

Am quite skeptical of the tests, while they’re not totally useless, they are quite susceptible to some minor difference in how optimizations are applied - giving a bias to one runtime over another - which would turn out totally different given a different micro-benchmark.

For example, I did some quick tests and PyPy performs 5.3x better when the loop is in a function
(in practice you probably wont do nested loops in global name-space anyway).

And while solutions that are automatic are great (no manual messing about), In my tests I managed to have CPython 1.8x faster than LuaJIT using Numba (http://numba.pydata.org), where you can add a @jit decorator to number crunching functions.
If this is important to support we could include numba with Blender eventually, instead of switching/adding run-times.
Test scripts Numba/LuaJIT for reference http://members.iinet.net.au/~ideasman42/simple_py_lua_loop_bench/

Generally, there is quite a lot of work going on to improve CPython performance (check the Pyjion project which is working on plug-able JIT support in CPython),
on the other hand… this has been the case for some years now and CPython still doesn’t have this officially supported.

I would be opposed to duplication and fragmentation of effort introduced by say the addition of lua or replacing python. As a hobby artist I have acquired a smattering of python scripting ability to hack basic things together as I need but not a lot of time for still more learning or to be too fancy. I can find my way around the now fairly extensive community python resources to find code snippets, ideas and help. There would have to be numerous significant benefits to warrant a change IMO. While its obviously not as fast as C I don’t consider python to be slow enough in usual use to be an obstacle to most Blenderheads. Unless you are working with very large data whats a few seconds here and there? I submit while not ideal for everything python is adequate and established as a working solution in the Blender universe. What are the specific issues the person has with coding things that has prompted this suggestion I wonder? We cant be just be looking over the fence at greener grass…

do you have any plan to develop addon in lua?

Using lua in Blender is a big project, unlikely anyone will be using this unless they’re experienced and have some weeks to dedicate to it.
Though there are some options to integrate other languages into Python.

Surprising, not bad for numba that I don’t know it.

Yes, i am aware that it may take effort, if ever they integrate Lua, they can always extend and customize according to their need for speed.

On the ohter hand, Lupa a Python wrapper around Lua and LuaJIT sounds good we’ll see if it is stable.

> Options to integrate other languages using cpython eg Lupa.
If @threedslider believes there will be a performance issue with a project he has he might like to explore this as the way to get around the perceived limitations of python. Probably we are talking about a higher skill level or awareness of coding than most Blender artists have however.
If the coder is savvy enough to be concerned about such things they will probably be able to employ tools to leverage the existing python facility on occasion rather than need to incorporate a whole new language with all that entails and at this point doesn’t seem practical.
Although python is entrenched in Blender it isn’t inadequate such that we need to actively pursue alternatives IMO :slight_smile:

Performance is usually not a good reason to use Lua. There are others, but performance is for sure not one of the strengths.

Python is flexible, and fast enough to be a sort of glue linking together C code,

the idea is, pass pointers etc to large collections of data between C functions,

(think nodes, but the area connecting them is python)

Python is plenty fast enough to be a Conductor, with C playing the Orchestra.

I have been able to sort large data sets on the fly, by using Arrays and Trees, dictionaries etc,

it’s not about how heavy the nail is,

For instance, you can dynamic paint at 60 fps in the game engine using python,

I don’t see any REAL benefit in changing the scripting / extension language used. Most problems are related to the programmers, not the language used.
If I can say this, my concern relies on that Blender has too many weak points of extension. For example, “new compositing nodes”, “new effects strips”,… created through a plug-in system.

It isn’t to believe from perfomance but rather is what you see is what you get, if we see Lua what provides and a lot of great company use it, by example for game WoW, Love2D, Stingray, Leadwerks and many other too. If I am to understand I am not a higher skill but just a user which suggests another alternative of programming. Python is great for making task however Lua is better for making games in my opinion as says previous.

Perhaps it’s a stupid question, but… Is there much of a benefit in supporting other languages with Blender’s source being open for all sorts of new development?

There’s a lot of libraries and functionality in Blender that’s not exposed to the Python API. That would be an absolutely lovely place to start if one wanted to make a more powerful scripting functionality for Blender.

Extending the Python API is ia nice way to get into Blender development, (lots of example code to use as a reference and you can start with quite simple tasks).
Mostly we add new functionality when developers notice it and tell us… (or when we need it).
Feel free to post to the bf-python mailing list, suggest API additions on rightclickselect.com (possibly both).

I’ve never programmed in a non OOP language but eh let’s get back on topic,

LUA is awesome

but wouldn’t you have to revamp blender from the ground up to make it lua compatible?

Imagine all the broken add ons

Not really. There’s nothing in the blender code that prevents adding another script interface: you keep the current one and add a new one, either to specifically support lua or to add a variety of languages.
The good news is that “just adding” allows the program to be backward compatible, the bad news is that you’ll have two script interfaces in the codebase to maintain (that is fixing bugs and adding features).
Time being the scarce resource it is, that’s very bad news.