On 07/25/2011 05:48 AM, Steven D'Aprano wrote:
But if you're calling a function in both cases:

map(int, data)
[int(x) for x in data]


I am aware the premature optimization is a danger, but its also incorrect to ignore potential performance pitfalls.

I would favor a generator expression here, if only because I think its easier to read. In addition, it properly handles large amounts of data by not duplicating the list. For very long input sequences, genexp would be the proper thing to do (assuming you don't need to index into results, in which case, its wrong.)

I think the fastest way to solve the OP's problem is the following: ;)

def convert_165_0_to_int(arg):
    return 165


--
Bill
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to