is it possible to use stdenumerator for alternative to yield python code #111
-
Hello,
my actual VBA code ( works but slower x30 than python . Tuples replaced by collection) :
Elements are Double Example :
GroupSum = 135,33502 i guess that yield reduces the number of generated subsets. Thanks ! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
You're creating a new collection each round trip, that's bound to be slow. I'd be using arrays if I were you and ensuring memory re-use where ever possible. Maybe even a UDT which can keep track of sum of each subset too: Type SumSubset
sum as Double
count as Long
subset() as Double
End Type
Function SumSubset_AppendElement(subset as SumSubset, element as double) as SumSubset
Dim t as SumSubset
LSet t = subset
t.sum = t.sum + element
t.count = t.count + 1
redim preserve t.subset(1 to t.count)
t.subset(t.count) = element
LSet SumSubset_AppendElement = t
End Function In answer to your question you can't do any type of |
Beta Was this translation helpful? Give feedback.
-
Hello
UDT is faster than Collection : with Call to Javascript Function (yield instructions included) : Total time recorded: 2,27 s Friendly, J.P |
Beta Was this translation helpful? Give feedback.
Thanks for this answer. So don't spend more time on this problem. I have found another solution --> i have written a function in csharp language (yield exists in this language) and use Excel-Dna to call it and get the solution in VBA. Under one second to have the solution.