brown-ccv / icesat2waves

ICESat-2 track analysis
GNU General Public License v3.0
0 stars 2 forks source link

I didn't notice this before either, but these functions (`get_var`, `get_N`, `get_lat`) are used in a map call and need updated data in each iteration. I am curious about what might be a faster approach. One could define more general functions outside of the loop and then pass the data that is needed using a [lambda expression](https://docs.python.org/3/reference/expressions.html#lambda:~:text=about%20conditional%20expressions.-,6.14.%20Lambdas%C2%B6,-lambda_expr%20%3A%3A%3D%20%20%22lambda%22%20%5B) or a [partial function](https://docs.python.org/3/library/functools.html#functools.partial). In all three approaches 3 functions are created in each iteration. Hard to say which is the fastest without profiling. #157

Open kmilo9999 opened 4 months ago

kmilo9999 commented 4 months ago
          I didn't notice this before either, but these functions (`get_var`, `get_N`, `get_lat`) are used in a map call and need updated data in each iteration. I am curious about what might be a faster approach. One could define more general functions outside of the loop and then pass the data that is needed using a [lambda expression](https://docs.python.org/3/reference/expressions.html#lambda:~:text=about%20conditional%20expressions.-,6.14.%20Lambdas%C2%B6,-lambda_expr%20%3A%3A%3D%20%20%22lambda%22%20%5B) or a [partial function](https://docs.python.org/3/library/functools.html#functools.partial). In all three approaches 3 functions are created in each iteration. Hard to say which is the fastest without profiling.

_Originally posted by @cpaniaguam in https://github.com/brown-ccv/icesat2-tracks/pull/132#discussion_r1508263077_