rvalue has quit [Read error: Connection reset by peer]
rvalue has joined #ruby
grenierm has joined #ruby
Aminda has quit [Remote host closed the connection]
Aminda has joined #ruby
_ht has joined #ruby
crespire has quit [Killed (NickServ (GHOST command used by crespire1))]
crespire1 has joined #ruby
Aminda has quit [Remote host closed the connection]
Aminda has joined #ruby
Linux_Kerio has quit [Ping timeout: 246 seconds]
Trivial has joined #ruby
TomyWork has joined #ruby
grenierm has quit [Ping timeout: 250 seconds]
Al2O3 has quit [Ping timeout: 256 seconds]
jmjl- is now known as jmjl
dalan03822833508 has joined #ruby
hightower2 has quit [Ping timeout: 255 seconds]
u0_a115 has joined #ruby
u0_a1151 has joined #ruby
karolis_ has joined #ruby
u0_a115 has quit [Ping timeout: 272 seconds]
karolis_ has quit [Remote host closed the connection]
dalan03822833508 has quit [Read error: Connection reset by peer]
dalan03822833508 has joined #ruby
u0_a1151 has quit [Ping timeout: 240 seconds]
gaussianblue has quit [Quit: leaving]
Linux_Kerio has joined #ruby
Linux_Kerio has quit [Read error: Connection reset by peer]
Starfoxxes has quit [Ping timeout: 268 seconds]
Al2O3 has joined #ruby
Starfoxxes has joined #ruby
xkoncek has quit [Ping timeout: 255 seconds]
passbe has quit [Quit: bye...]
passbe has joined #ruby
<sam113101>
guys explain something to me
<sam113101>
why is num.prime? much faster than Prime.prime?(num)
<sam113101>
I think I already asked this but I don't remember
<konsolebox>
The latter sensibly has more internal calls in it. But other than that it's gotta be the implementation. Prime (https://github.com/ruby/prime) is not written in C.
<sam113101>
konsolebox: They're both from that lib and they're both written in ruby. num.prime? comes from the lib injecting into Integer, it's not a default ruby function. But indeed they have a different implementation, and I'm starting to understand why one is faster than the other. I still wonder, why even have the slower one at all? Why not just make them both the same.
<weaksauce>
sam113101 havenwood has some thoughts on that
<weaksauce>
anyway it boils down to the prime library is a toy implementation
<weaksauce>
not sure why the first one is faster
<konsolebox>
It also needs context. Faster in the call itself alone or multiple calls?
xdminsy has quit [Read error: Connection reset by peer]
Al2O3 is now known as Hoppy420
<sam113101>
first one is faster because it does a Miller Rabin test with a limited set of bases, whereas the other one basically does a simple division test with numbers that are not divisible by 2 and 3
<sam113101>
and from what I understand it's also checking numbers greater than the square root
<weaksauce>
sam113101 where is num.prime? coming for
<weaksauce>
from*
<weaksauce>
it's not in integer or numeric from what i can tell