Hi, On Friday, July 7, 2017 at 6:48:01 PM UTC+2, Andy Balholm wrote: > > That’s normal for languages like Python. The code that is actually running > in Python is slow, but library functions are fast, because they are written > in C. >
Sure ... that's why I wrote the 'naive explanation' that says basically that :-) The question remains, whether there is a better way to do it. I was first taking DivMod, then tried Mod in the hope that it would be faster (I don't need the quotient) ... I even tried ExpMod with an exponent of 1, which didn't quite work for some reason I don't really understand; a.Mod(stufffff, ...) seems to set "a" to one value, but a.Exp(stuff, one, ....) sets it to a different value, or not, depending on exactly where in the loop I do it. My conclusion from that is that I don't really understand pointers / receivers in Golang yet :-) JT > The naive explanation would be that Mod in Go math/big is about just as > fast as the % primitive in python (Python has big integers automatically > where needed) but the rest of the program is a factor of 10 or so faster in > Go than Python. I wonder though, especially if there is a better way to > take a Mod. The numbers are not THAT large (less than 100 decimal digits > in most cases) ... > > (pprof) top10 -cum > 13.01s of 41.11s total (31.65%) > Dropped 86 nodes (cum <= 0.21s) > Showing top 10 nodes out of 74 (cum >= 6.66s) > flat flat% sum% cum cum% > 0 0% 0% 40.45s 98.39% runtime.goexit > 0 0% 0% 40.20s 97.79% main.main > 0 0% 0% 40.20s 97.79% runtime.main > 0.28s 0.68% 0.68% 40.19s 97.76% > _/Users/templon/gofact/factoring.Mybrent > 0 0% 0.68% 40.19s 97.76% > _/Users/templon/gofact/factoring.Trial_n_X > 0.44s 1.07% 1.75% 29.42s 71.56% math/big.(*Int).Mod > 0.77s 1.87% 3.62% 28.98s 70.49% math/big.(*Int).QuoRem > 0.51s 1.24% 4.86% 28.18s 68.55% math/big.nat.div > 10.39s 25.27% 30.14% 27.47s 66.82% math/big.nat.divLarge > 0.62s 1.51% 31.65% 6.66s 16.20% runtime.makeslice > > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts...@googlegroups.com <javascript:>. > For more options, visit https://groups.google.com/d/optout. > > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.