Slow startup on Windows for virtual environments

The relevance of conda here is that (as far as I know), neither Anaconda nor conda-forge sign the binaries in their packages. So the virus scanners will always treat them as untrusted and do the full range of scans before letting them run.

Binaries from python.org (which I produce) are all signed, including the PowerShell scripts, and we deliberately avoid modifying them (which would break the signature and make things worse). As a result, they don’t get the same level of scanning, and generally start up much faster.

The Store install unfortunately degrades things a little bit, because it has to use some expensive APIs at startup to locate itself, but should be completely exempt from virus scans because it’s gone through the Store verification process already. I’m working on a complete replacement that ought to resolve that side of things, at the expense of bringing back the virus scans. Unfortunately, it’s all a big balancing act.

Best case scenario for startup time is to make your own app, embed the Python embeddable distro, remove any unused extension modules, create your own entry point, and either publish through the Windows Store[1] or sign the whole thing with your own code certificate and make an installer that installs into Program Files. My implementation of the “complete replacement” linked above uses this approach, along with 1-2 other tricks that I know I can get away with (being on the “inside”, as it were), and it works great.


  1. We only need the expensive APIs to emulate what developers expect from CPython. It’s not necessary just to use Python in your app, only if you want stuff like python -m pip install ... to work. ↩︎

3 Likes