Python too slow?
sturlamolden at yahoo.no
Fri Jan 11 18:24:35 CET 2008
On 9 Jan, 20:11, "dongie.ag... at gmail.com" <dongie.ag... at gmail.com>
> Is there a better way to do color tracking, or is Python just too slow
> as an interpreted language to do any effective color tracking?
You should code numerically intensive tasks using NumPy arrays. If
things are getting slow, chances are you are using Python for loops
instead of vectorized NumPy expressions. This is the same trick you
would use in e.g. Matlab for boosting performance. If things are
running slow despite of having properly vectorized your code, chances
are that porting to C will not make a big difference.
If you need to resort to C or Fortran, it is easy to interface Python
with these languages (e.g. ctypes, Pyrex, Swig, f2py, or weave). Put
the offending bottleneck in a lower level language (detect it using
the profiler module) and leave everything else in Python.
More information about the Python-list