3 ms·
I honestly don't see much the value of generators here. we can simply return all the results directly from the xpath function that you created. Are there any us
by sktguha 6y ago
I honestly don't see much the value of generators here. we can simply return all the results directly from the xpath function that you created. Are there any use case where you would want to stream the elements one by one ? you have got all the results in memory anyways inside the xpath function
- Akronymus 6y agoTo me, it seems to support lazy evaluation much better with a generator. Additionally composability seems improved, due to all functions being able to be written in a way where they themselves become generators, so you apply all steps only to each result you retrieve. Potentially saving quite a bit of execution time, if you don't need the full collection.
- gridlockd 6y ago> you have got all the results in memory anyways inside the xpath function Not necessarily, that's an implementation detail. The result of an XPath query is not an array, it's some object that accepts integer indices for lookup. If you were to return an array, there would be no way to break out of iteration early without paying for every lookup. For something like XPath, breaking out early is a likely scenario.