Problem of function calls from map()

Sion Arrowsmith siona at chiark.greenend.org.uk
Tue Aug 22 12:18:14 EDT 2006


Fredrik Lundh <fredrik at pythonware.com> wrote:
>Sion Arrowsmith wrote:
>> I think there's something weird going on -- sp4 should be making
>> 154563 calls to str.split. So no wonder it goes faster -- it's not doing
>> any work.
>the problem is that he's using a Python-level profiler to benchmark things written
>in C.
>
>(you cannot really use "profile" to *benchmark* things written in Python either; the
>profiler tells you where a given program spends the time, not how fast it is in com-
>parision with other programs)

Hmm. Playing around with timeit suggests that although split() *is*
faster than split("\t"), it's fractional, rather than the OP's four
times faster. Is the overhead of profile keeping track of calls in
Python getting in the way? (Not having used profile -- hence my
confusion.) And why can map() keep everything at the C level when
the list comprehension can't?

-- 
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |    -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump



More information about the Python-list mailing list