Newbie question concerning map functionality
Alex Martelli
aleax at aleax.it
Wed Jun 18 04:16:52 EDT 2003
Henk wrote:
> I want to use the built-in map function to speed up the following for
> loop. But I somehow fail to incorporate the unction called in the
> argument. Can somebody help me out?
>
> for child in self.childNodes:
> clone.appendChild(child.cloneNode(1))
I very much doubt you can use map to speed this up; map only gives a
speed-up (and a modest one) when its first argument is a function you
need to call anyway. Adding a lambda so you can do anything but
calling a function (e.g., in order to call a method, as you're doing
here on each child) will no doubt dissipate any gain.
Alex
More information about the Python-list
mailing list