Closed kjartan-at-bravos closed 6 months ago
Gracias! Me parece bien. The size of the speedup is larger than I would've guessed so this is great! Eventually I'll try to re-route this __add__
to use this as well (to avoid duplicated code) and I might suggest renaming some of the api (I'm thinking perhaps the other should be called sum_over
and this should be called sum
or quicksum
)
Great! I think the naming you suggests makes sense. I am also curious to see how you would modify __add__
to work with a sequence of additions. I guess you could have self
maintain a list of other Expression object that has been added to it, and only do the final sum over the list when it is needed. Like a lazy evaluation.
A preliminary test showed me that the speed-up could be significant doing pl.concat on all the expresionnables' data instead of one by one as in an explicit sum
e1 + e2 + e3
.This PR proposes a function
sum_list(Iterable[SupportsToExpr])
that implements this.