--
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.
For more options, visit https://groups.google.com/d/optout.
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.
I noticed your “naive explanation” after I sent my message. But I think it is the real explanation.
func (z nat) shr(x nat, s uint) nat {
m := len(x)
n := m - int(s/_W)
if n <= 0 {
return z[:0]
}
// n > 0
z = z.make(n)
shrVU(z, x[m-n:], s%_W)
return z.norm() -j
-j
Just for fun: Please provide a sample in that range.
-j
2017-07-17 15:56 GMT+02:00 Jeff Templon <jeff.temp...@gmail.com>:
> it turns out that 77% of the time of the program is spent in
> runtime.mallocgc :-) I think the reason why is stuff like this:
>
> func (z nat) shr(x nat, s uint) nat {
> m := len(x)
> n := m - int(s/_W)
> if n <= 0 {
> return z[:0]
> }
> // n > 0
>
> z = z.make(n)
> shrVU(z, x[m-n:], s%_W)
>
> return z.norm()
>
> }
>
How are you writing your code ? Wisely using variables should only
cause very minimal memory allocation.