as kcrisman mentions, prod first gathers all the factors before it 
multiplies them together. It does so for a reason: it takes the product in 
a balanced fasion; not just going through the factors iteratively. I don't 
know if it does an early exit if any zeros are encountered, but the 
strategy of multiplying together in a tree-like configuration is a 
significant optimisation for many common cases.

On Thursday, 22 September 2022 at 07:39:03 UTC-7 axio...@yahoo.de wrote:

> sage: def test(n):
> ....:     print("n:", n)
> ....:     return n
> ....: 
> sage: l = [2,3,5,0,7,11,17,19]
> sage: prod(map(test, l))
> n: 2
> n: 3
> n: 5
> n: 0
> n: 7
> n: 11
> n: 17
> n: 19
> 0
> I expected that it would return 0 once we multiply with 0.
>
> Martin
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/f37b28a3-2622-43d9-8904-d06d599de477n%40googlegroups.com.

Reply via email to