Problem of function calls from map()

Fredrik Lundh fredrik at pythonware.com
Tue Aug 22 10:50:39 EDT 2006


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.

of course it does:

>>> lines = ["line\tone", "line\ttwo"]
>>> [s.split("\t") for s in lines]
[['line', 'one'], ['line', 'two']]
>>> map(str.split, lines)
[['line', 'one'], ['line', 'two']]

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)

</F> 






More information about the Python-list mailing list