in [Python]

From: Patrick Maupin on 6 Apr 2010 10:31 On Apr 6, 8:39 am, Albert van der Horst <alb... (a)spenarnc.xs4all.nl>wrote: > To a mathematician sum(set) suggest that the order of summation > doesn't matter. (So I wouldn't use sum for concatenating lists.) > Harshly, sum() should be used only for operator + both associative and > commutative. That's all well and good, but not every Python user is a mathematician. As long as Python doesn't surprise mathematicians in a way that is too negative (I can see the complaint now: "Hey! sum() kept my lists ordered! I was expecting some randomization!") what is wrong with it also not surprising the average user in a way that is too negative? Regards, Pat
From: Neil Cerutti on 6 Apr 2010 10:51
On 2010-04-06, Albert van der Horst <albert (a)spenarnc.xs4all.nl> wrote:> To a mathematician sum(set) suggest that the order of summation > doesn't matter. (So I wouldn't use sum for concatenating > lists.) Harshly, sum() should be used only for operator + both > associative and commutative. > > Now for floating point numbers the order of summation is > crucial, not commutative (a+b)+c <> a+(b+c). So the obvious > thing for someone versed in numerical computing do is looking > whether sum() gives any guarantees for order and whether there > may be a special sum() for floating point. (This is not very > realistic, because such a person would have skimmed the math > library a long time ago, but anyway.) I'm convinced by this argument. I just have to be a mathematician and a computer scientist skilled in numerical computing. No problem! Just a *few more years* of education and I'll be ready for summing things in Python. ;) -- Neil Cerutti |