Best method of using Python?


(chacademus) #1

Just a thought, what is the best way to use python with blender? Is it best to have the python written as external scripts or internal within blender, or neither? Would it effect the speed or anything?


(meestaplu) #2

Writing the scripts externally does not affect speed - as far as I know your code is interpreted the same way in both cases. Writing scripts externally is also easier; if you use something like IDLE you get syntax highlighting and various indentation options. The only drawback to writing scripts externally is having to go into Blender and update them every time you make a change.

Matt


(chacademus) #3

But if I have the scripts external, and the program needs to run a particular external script, is there not a time lag when it has to load it up and interpret it, as opposed to an internal one which could possibly be quicker as it is internal?


(theeth) #4

there’s a lag at the first run, even if you have it internally. That lag is due to the Python interpreter compiling the code. However, if you have it externally, a compiled version will be created only when the time stamp of the compiled file (the .pyc that is created when you first load it) doesn’t match the source code’s so, an external module will only lag the first time.

Martin


(gorgan_almi) #5

I’ve got a quite unique way of using python scripts which I think is the best way of doing it.

See my post titled Importing external pthon modules