Python/Harmattan/Performance Considerations for Python Apps

Based on |Making Python faster (for fmms initially) and |Python Qt startup time tips

= Profiling =

Do not worry about performance unless you notice a problem. Then only optimize what you can justify with profiling.

To profile Python code, run it with $ python -m cProfile -o .profile TOPLEVEL_SCRIPT.py To then analyze the results $ python -m pstats .profile > sort cumulative > stats 40

That sorted the results by the time it took for a function and all the functions it called. It then displays the top 40 results.

= Improving Performance =

Unladen Swallow
|PEP 3146 - Merging of Unladen Swallow

Currently Unladen Swallow has not seen too much performance benefit but has a longer start up time and takes more memory

Psyco / Cython
Do these work with Arm?

/usr/bin/python Startup
|PyLauncher was favored back in the Maemo 4.1 days but has fallen out of favor lately.

Perceived Startup Performance
|hildon_gtk_window_take_screenshot takes advantage of user perception to make the user think the app is launched faster.

Memory Usage
= FAQ =

Is Python slow?
The standard response of "it depends". For a graphical application not doing too much processing a user will probably not notice it is written in Python. Compare that to an experiment by epage in writing a GST video filter in python that at best ran at 2 seconds per frame.