As this is a PEP, there is no real code to create, unlike in previous chapters. What we will do is cover the details of the proposal and how they are intended to be implemented:
- Two new APIs would be added to the gc module:
- The gc.set_mode(mode) API configures the garbage-collection mode between serial and threaded. If it is currently set to threaded, but the setting is switched to serial, the function waits for the garbage collection thread to complete before changing.
- The gc.get_mode() API returns the current mode of operation.
- The collection mode can be switched between the two options, so it is recommended that it be set at the beginning of a program, or when child processes are created.
- The actual implementation happens ...