Recompilation depends on package include order?


I have a situation where I’m seeing different load times of packages depending on the order I include them. If I first include PyCall and then include Dates, the Dates package recompiles. However, if I do it the other way around, first include Dates and then include PyCall, the Dates package doesn’t recompile. PyCall always recompiles irrespective of the order in which it is included. I’m using version 1.8.4 of Julia. Is this expected? I also see this with other packages like Printf. None of the packages have been changed between the two runs.

Is there something I’m doing that causes recompilation even when the package has not changed?

user@host:~$ julia

julia> @time using PyCall
  0.930808 seconds (1.05 M allocations: 70.188 MiB, 1.30% gc time, 65.77% compilation time)

julia> @time using Dates
  2.019611 seconds (2.59 M allocations: 131.783 MiB, 1.00% gc time, 99.99% compilation time: 99% of which was recompilation)

julia> exit()
user@host:~$ julia

julia> @time using Dates
  0.006764 seconds (8.27 k allocations: 518.733 KiB)

julia> @time using PyCall
  0.911106 seconds (1.04 M allocations: 69.587 MiB, 2.08% gc time, 66.61% compilation time)

julia> exit()
julia> versioninfo()
Julia Version 1.8.4
Commit 00177ebc4f (2022-12-23 21:32 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, skylake)
  Threads: 1 on 8 virtual cores

You probably not, but it’s likely the package PyCall which is doing something wrong, perhaps like invalidating methods in Dates.

1 Like