views:

116

answers:

2

Are their any ways to optimize Jython without resorting to profiling or significantly changing the code?

Specifically are there any flags that can be passed to the compiler, or code hints in tight loops.

+6  A: 

No flags, no code hints. You can optimize by tweaking your code much as you would for any other Python implementation (hoisting, etc), but profiling helps by telling you where it's worth your while to expend such effort -- so, sure, you can optimize "without resorting to profiling" (and the code changes to do so may well be deemed to be not significant), but you're unlikely to guess right about where your time and energy are best spent, while profiling helps you determine exactly that.

Alex Martelli
Thank you for your response, but, this question is not really how to do profiling, but more so what optimizations are available without profiling. Re-worded the question might read, "Help, I've optimized everything and it is still too slow executing some Java code in Python, what can I do without re-writing in Python?". I'm not fully convinced the answer is nothing.
Bear
As I mentioned, the usual optimizations (hoisting -). If you have indeed applied them all everywhere (without profiling to check if they'd be any use) then your code is by now an unreadable, unmaintainable mess -- I doubt that's the case, but it's impossible to **know** without actually seeing the code. Why _don't_ you profile and thereby learn **where** the performance bottlenecks **are**?!
Alex Martelli
+1  A: 

Jython compiler does not offer lots of optimization choices. However, since the Java virtual machine (java) and perhaps compiler (javac) are getting invoked in the back end or at runtime, you should take a look at them.

Java has different runtime switches to use depending on whether you are going to launch it as a server process, client process, etc. You can also tell how much memory to allocate too.

JohnnySoftware