Optimisation problem - in C?

Sebastian Dauss sebastian.dauss at web.de
Wed Feb 21 15:47:42 CET 2001


Sorry for replying to my own message, but exactly the function you need does
already exist! It is included within the "mxTools" package:
    http://www.lemburg.com/files/python/mxTools.html
and named "extract".

So, what you really want (I hope so! ;) ) is:

  import mxTools
  def makevector_mxTools(sourcelist,elementlist):
      return mxTools.extract(sourcelist, elementlist)

And for performance considerations, take this:

   Runtime UsrTim SysTim Count  TimerName
  0.474198   0.47   0.00     1: makevector
  0.347249   0.34   0.00     1: makevector_listc
  0.214850   0.21   0.00     1: makevector_noappend
  0.212961   0.21   0.01     1: makevector_lambda
  0.180423   0.18   0.00     1: makevector_operator
  0.060965   0.06   0.00     1: makevector_mxTools

So, using mxTools results in a runtime that is 3 times faster than the
(probably) best "map-magic" in pure python.


Hope that really helped ;),
    Sebastian.







More information about the Python-list mailing list