Mysterious allocations in nested scalar loops

It’s probably the isprime function. It allocates for some large integers.

julia> @btime isprime(65521)
3.268 ns (0 allocations: 0 bytes)
true

julia> @btime isprime(65537)
212.412 ns (1 allocation: 16 bytes)
true

julia> @btime isprime(6553765601)
4.250 μs (0 allocations: 0 bytes)
true

julia> @btime isprime(1000723)
474.679 ns (1 allocation: 16 bytes)
true

1 Like