This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients benrg, mark.dickinson, rhettinger, tim.peters
Date 2022-03-01.01:32:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1646098342.09.0.0194288553258.issue46868@roundup.psfhosted.org>
In-reply-to
Content
About runtime, you're right. I did a ballpark "OK, if there are N incoming values, the inner loop has to go around, for each one, looking for a NULL, across a vector of at most log2(N) entries. So N * log2(N)". But, in fact, it's highly skewed toward getting out early, and 2*N is an upper bound on the total number of inner loop iterations. Strongly related to that the total number of trailing 1 bits in the integers from 1 through N inclusive is N - N.bit_count().

For the rest, I'll only repeat that if this goes in, it should be as a new function. Special-casing, e.g., math.prod() is a Bad Idea. We can have no idea in advance whether the iterable is type-homogenous, or even whether the __mul__ methods the types involved implement are even intended to be associative. 

functools.reduce() clearly documents strict "left to right" evaluation.

But a new treereduce() can do anything it feels like promising.
History
Date User Action Args
2022-03-01 01:32:22tim.peterssetrecipients: + tim.peters, rhettinger, mark.dickinson, benrg
2022-03-01 01:32:22tim.peterssetmessageid: <1646098342.09.0.0194288553258.issue46868@roundup.psfhosted.org>
2022-03-01 01:32:22tim.peterslinkissue46868 messages
2022-03-01 01:32:21tim.peterscreate