views:

338

answers:

3

Hi, i'm working with pydev + jython.great ide , but quite slow when i try to run a jython program. this is probably something due to libraries load time.

What can i do to speed it up ?

Thanks , yaniv

A: 

same problem with cpython , any suggestions?

Shay

Shay
+1  A: 

If you have a machine with more than one processor you could try starting eclipse/pydev with the options -vmargs -XX:+UseParallelGC You could also try different JVMs to see if any of them give better performance.

Stuart
A: 

Jython startup time is slow ... there's a lot to bootup!

Everytime you run a Jython script from scratch, it will incur the same Jython startup time cost.

Hence, the reason Jython, Java, and Python are not great for CGI invocations. Hence, the reason for mod_python in Apache.

The key is to start-up Jython once and reuse it. But this is not always possible especially during development because your modules are always changing and Jython does not recognize these changes automatically.

Jython needs a way to know which modules have changed for automatic reloads. This is not built into Jython and you'll have to rely on some other third party library to help with this. The concept is to remove from 'sys.modules' the modules which have changed. A simple solution is to just clear all the modules from sys.modules - which will cause all modules to be reloaded. This is obviously, not the most efficient solution.

Another tip is to only import modules that your module needs at the time that it 'really' needs them. If you import every module at the top of your modules, that will increase your module import cost. So, refactor imports to within methods/functions where they are needed and where it 'makes sense'. Of course, if your method/function is computation heavy and is used frequently, it does not make sence to import modules within that method/function.

Hopefully, that helps you out!

Tiger Woods