Cache multiple identical map_elements
calls within a function call
#13895
Labels
enhancement
New feature or an improvement of an existing feature
Description
I asked a question about
map_elements
in Discord and @MarcoGorelli suggested that I add a feature that addresses some optimizations (will need clarification on this point). I want to run a UDF (or third-party library function) with multiple return values and assign those specific values to different columns. In my case, I am looking for a way to run the function once per item because it is computationally heavy. If any one of these methods is the preferred way to do things, I think it will be helpful to add it to the documentation.Multiple function calls per row (total = number of rows * number of new cols)
In this example, you can see that the function is run twice (for each
get()
call)One function call per row (total = number of rows)
In this example, the function isn't called multiple times for the same column. This is closest to what I was looking for, but we do have to create this r column and then delete it. I believe this is where the aforementioned optimization can come in. I am not sure how to tackle this exactly, but I would like to see a similar syntax or argument that allows you keep/drop the "result".
Note: Unnest a dictionary of return elements
This might work if you define the function yourself. I think it would be tedious to make a wrapper around a third-party library so that it returns a dictionary.
I tried reading the
enhancement
tags for something that specifically matched this but didn't find anything. @MarcoGorelli if I missed something in the feature request, please let me know.The text was updated successfully, but these errors were encountered: