Windows Subsystem for Linux 有点垃圾.它有很多很多错误,而且它比它需要的要慢得多.这只是另一个表现出来的错误.以下是一些可能的瓶颈:
Windows Subsystem for Linux is a bit rubbish. It's got many, many bugs and it's significantly slower than it needs to be. This is just another bug manifesting itself. Here are some possible bottlenecks:
- WSL 中的上下文切换缓慢.
- WSL 没有注意到等待管道的整个进程意味着现在应该运行管道的另一端.
- 延迟执行的子进程.
- Windows 需要一段时间才能确定它需要使用
wsl.exe
来启动程序(感谢 RoadRunner!)
- Windows 的常规开销,加上 Linux 的常规开销(相对较小).
- 一个糟糕的 Ubuntu 发行版选择导致许多不必要的服务在
systemd
(?) 中运行- Windows 出于某种未知原因决定在子进程之前运行其他内容.
-
Windows 子系统对 Linux 开发人员的蓄意恶意,合谋通过设置稻草人来证明"Windows 是卓越的操作系统. 太愚蠢了.
- Slow context switching in WSL.
- WSL not noticing that an entire process waiting for a pipe means that the other end of the pipe should be run now.
- The child process being executed lazily.
- Windows taking a while to figure out that it needs to use
wsl.exe
to launch the program (thanks RoadRunner!)
- The usual overhead of Windows, plus the usual (comparatively small) overhead of Linux.
- A poor choice of Ubuntu distro causing many unnecessary services to be running in
systemd
(?)
- Windows deciding to run other stuff before the child process for some unknown reason.
-
Deliberate malice on the part of the Windows Subsystem for Linux developers, conspiring to "prove" that Windows is the superior operating system by setting up a strawman. Too silly.
您的 Python 代码没有任何问题会导致速度变慢.
There's nothing wrong with your Python code that would make this slow.