How can I get rid of lambda

Ben Wolfson wolfson at midway.uchicago.edu
Sun Oct 15 22:08:50 EDT 2000


In article <39EA484C.C57D995A at gte.net>,
Steve Williams  <sandj.williams at gte.net> wrote:
>I'm working with IBM packed decimal data.  The following code works OK,
>but there are millions of rows and 10 to 50 columns per row.  I want as
>much speed as I can get.
>
>How can I avoid the lambda in the following unpack function?  Or better,
>is there a faster way?
>
>By the way, if you want a testimonial to Python's capabilities, do a
>Google search on 'packed decimal' and have a look at some of the Java
>solutions to this problem.
>
>def unpack(strPacked):
>    return fnJoin(map(lambda chrLeft, chrRight: chrLeft + chrRight,\
>        fnTranslate(strPacked,_trtLeftNybble),\
>        fnTranslate(strPacked,_trtRightNybble)),"")

Try importing the operator module, and using operator.add instead of the
lambda.


-- 
BTR  |  It is a symptome of Melancholy to be afraid of death, and yet
sometimes to desire it; this latter I have often discovered in my selfe, and
thinke noe man ever desired life as I have sometimes Death.
 -- Thomas Browne, _Religio Medici_



More information about the Python-list mailing list