Qualtran
Qualtran copied to clipboard
Importing qualtran is very slow (~3.2s)
import timeit
t = timeit.timeit('import qualtran', number=1)
print(t)
averages around 3.2s. Perhaps some dependency is causing this.
(Alternatively run python -m timeit -n 1 -r 1 "import qualtran")
do you want to do some profiling to figure out what might be the cause?
I ran python -X importtime -c "import qualtran" (after #949), it seems import cirq takes up most of the time:
import time: self [us] | cumulative | imported package
...
import time: 1377 | 1072314 | cirq
import time: 4683 | 1076997 | qualtran._infra.gate_with_registers
...
import time: 349 | 1564730 | qualtran
It would be nice if we could defer importing cirq "as needed" as well. Ideally, this would only happen if you were using a bloq that wraps a cirq gate or uses cirq functionality somehow (or if using any of the cirq interop). It's blocked by the fact that GateWithRegisters is in the top-level namespace and descends from cirq.Gate.