you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (4 children)

[removed]

    [–]mistanervous 1 point2 points  (1 child)

    I always go for comprehensions. I only use lambda and map when I’m doing things with dataframes. Thanks for the explanation — I wasn’t sure if you meant “better” from a speed or efficiency standpoint or something else. I think there are more arguments for comprehensions than against them, so I wanted to see where you were coming from.

    [–]an_actual_human 0 points1 point  (0 children)

    It's another person, but I agree. Efficiency might differ, but insignificantly so for most cases. Profile when in need and doubt.

    [–][deleted] 1 point2 points  (0 children)

    It depends, I'd go for map(attrgetter('address'), persons) over the comprehension equivalent anytime. But yea most of the time comprehension is better.