趣学Python游戏编程》代码.rar
2021-05-12 14:02:21 5.24MB pythoin
1
2019 Apress出版 The Python programming language adopted a preemptive concurrency framework in the early 90s via the threading module, which strived to mimic the Java concurrency library, as per the respective commit message. A simple but powerful mechanism governs concurrent execution of bytecode in most Python implementations. This mechanism is called the GIL (global interpreter lock). The interpreter consumes one bytecode instruction at a time. This effectively means that only one thread can run at the same time (in one interpreter process). Despite this fact, the underlying native thread implementation might be able to run more than one thread at a time. The threads are appointed “fair” amounts of CPU time. Without employing sophisticated introspection techniques, this boils down to simple/naive time-based scheduling algorithms. Taking this approach in the past would often yield inferior solutions to an equivalent single threaded program, for Python implementation with a GIL like CPython. Since removing the GIL is not an option,1 and prior attempts like Python safe-thread2 failed because they degraded the single threading performance significantly, the concurrency situation meant having only the threading module
2020-01-10 03:09:48 2.5MB Pythoin
1