Threading/map question
Anand
anandpillai6 at yahoo.com
Fri Dec 6 00:34:52 EST 2002
Michael Hudson <mwh at python.net> wrote in message news:<m24r9szcx0.fsf at localhost.bris.ac.uk>...
> anandpillai6 at yahoo.com (Anand) writes:
>
> > A question about function performance.
> >
> > I have a list of integers on which an operation is to be performed,
> > say an addition or subtraction. Since the list is huge (len >= 100000)
> > ,I can do it in two ways (I thought)
>
> OK.
>
> > I found that the thread solution takes lesser time than the map
> > solution. Can this be a general approach for all data structures in python
> > or does it apply only to lists.
>
> Asking if threading or map gives better performance seems to me like
> asking whether mashed potatoes or tofu are better at keeping one dry.
Thank You.
>
> However,
>
> ldataout = [None]*len(ldatain)
> for i in range(len(ldatain)):
> ldataout[i] = 255 - ldatain[i]
>
> is likely to be quicker than
>
> ldataout = map(lambda x: 255 - x, ldatain)
>
> because you don't have to take a trip through the function call
> machinery for each element of the list in the first case.
>
Guess I will stick with using mashed potatoes :-)
I found a combination of mashed potatoes and tofu to be
faster than using mashed potatoes / tofu by themselves or standing
in the rain.
> Cheers,
> M.
Thanks
Anand
More information about the Python-list
mailing list