ENH: Less memory for apply_function