<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Drat. This should have gone to python-ideas.<div>Re-sending.<br><div><br><div>Begin forwarded message:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1);"><b>From: </b></span><span style="font-family:'Helvetica'; font-size:medium;">Raymond Hettinger <<a href="mailto:raymond.hettinger@gmail.com">raymond.hettinger@gmail.com</a>><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1);"><b>Date: </b></span><span style="font-family:'Helvetica'; font-size:medium;">October 15, 2010 1:00:16 PM PDT<br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1);"><b>To: </b></span><span style="font-family:'Helvetica'; font-size:medium;">Python-Dev Dev <<a href="mailto:python-dev@python.org">python-dev@python.org</a>><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1);"><b>Subject: </b></span><span style="font-family:'Helvetica'; font-size:medium;"><b>Fwd: [Python-ideas] stats module Was: minmax() function ...</b><br></span></div><br><div>Hello guys. If you don't mind, I would like to hijack your thread :-)<br><br>ISTM, that the minmax() idea is really just an optimization request.<br>A single-pass minmax() is easily coded in simple, pure-python,<br>so really the discussion is about how to remove the loop overhead<br>(there isn't much you can do about the cost of the two compares<br>which is where most of the time would be spent anyway).<br><br>My suggestion is to aim higher. There is no reason a single pass<br>couldn't also return min/max/len/sum and perhaps even other summary<br>statistics like sum(x**2) so that you can compute standard deviation <br>and variance.<br><br>A few years ago, Guido and other python devvers supported a<br>proposal I made to create a stats module, but I didn't have time<br>to develop it. The basic idea was that python's batteries should<br>include most of the functionality available on advanced student<br>calculators. Another idea behind it was that we could invisibility<br>do-the-right-thing under the hood to help users avoid numerical<br>problems (i.e. math.fsum(s)/len(s) is a more accurate way to<br>compute an average because it doesn't lose precision when<br>building-up the intermediate sums).<br><br>I think the creativity and energy of this group is much better directed<br>at building a quality stats module (perhaps with some R-like capabilities).<br>That would likely be a better use of energy than bike-shedding <br>about ways to speed-up a trivial piece of code that is ultimately<br>constrained by the cost of the compares per item.<br><br>my-two-cents,<br><br><br>Raymond<br></div></blockquote></div><br></div></body></html>